c# - Task.Factory.StartNew invoked on UI thread anyhow -
i have deal strange problem, @ least point of view. use task wait untill variable gets specific value , run continue part on ui thread again.
problem before call startnew() , inside call managedthreadid same , freezes ui.
here code:
// managedthreadid here task.factory.startnew(() => { // , here same. while (isclosing) { thread.sleep(50); } }).continuewith((finishedtask) => { if (currentcontainer != null) { window = currentcontainer; } else { window = createballonwindow(); window.show(); } window.activate(); }, taskscheduler.fromcurrentsynchronizationcontext());
ideas?
thanks christoph
edit:
most interesting me why happens not how around issue. want understand happens there...
thank hints,
i think got it. problem here taskscheduler.current default scheduler used when calling startnew() . , no combination when using taskscheduler.synchronizationcontext().
the case here (indirectly) used startnew() in continuing task scheduler described taskscheduler.synchronizationcontext(). default scheduler 1 contains ui thread --> new task got invoked on ui thread.
special viv, sharing link. helped lot understand going on.
christoph
Comments
Post a Comment