c# - UI unable to update -
c# - UI unable to update -
i've got resource-heavy method takes few seconds execute. have decided invoke within task display waiting icon while task carried out.
what i've done called imgloading.visibility = visibility.visible
before creating task, , creating task. 1 time task complete, phone call imgloading.visibility = visibility.collapsed;
.
for reason, image never collapses , stays visible indefinitely. unusual issue quite easy recreate. code i've got, , can't see i've done wrong:
imgloading.visibility = visibility.visible; var validitytask = task.factory.startnew(() => expensivemethod(param1,param2)); validitytask.continuewith((previoustask) => { bool isvalid = validitytask.result; if (isvalid) { //do ui } else { //do ui } imgloading.visibility = visibility.collapsed; }, taskscheduler.fromcurrentsynchronizationcontext());
as code demonstrates, trying show imgloading
image while task carried out, , hide icon when task complete. current code, icon remains visible after task complete.
what doing wrong?
after time i've managed solve problem. posting here incase might help in future. problem block wasn't entering @ apparently. solution remove ui code task, , worked :)
c# .net wpf multithreading visual-studio-2010
Comments
Post a Comment