wpf - New Thread for Loading animated Gif -
i have read countless pages on how can achieved none seem working me.. wonder if because using wpf??
i have image control on wpf page holds animated gif. initial visibility property set hidden - idea being become visible when user logs in , disappears once login has been achieved.
so, first thought make image visible on button click - carry out grunt work hide again. image never gets displayed until after processing has completed - rendering idea useless one.
so, after bit of digging seems people have achieved processing new thread , using background worker object. have tried continually error:
the calling thread cannot access object because different thread owns it.
my code follows:
global variable thread object:
friend g_thloading thread
on button click login on have:
private sub btnloginok_click(sender object, e routedeventargs) handles btnloginok.click g_thloading = new thread(addressof loadingimage) g_thloading.isbackground = true g_thloading.start() try ... heavy processing takes while ... catch liex unauthorizedaccessexception txbresults.text = liex.message() catch ex exception msgbox(ex.message) end try g_thloading.abort() end sub
then method making image visible:
public sub loadingimage() imgloading.visibility = visibility.visible end sub
i have read posts error message stating freeze object (cannot see how works) , @ using dispatcher - little lost on me though every example have tried not work.
Comments
Post a Comment