c# - Thread was being aborted on a delegate -
i getting type of error on below function:i have handled threadexception still getting such error:
private void tmronesec_tick(object sender, eventargs e) { tsspendtime = tsspendtime.add(new timespan(0, 0, 1)); tsremtime = tstotaltime.subtract(tsspendtime); if (tsremtime.ticks > 0) clscommonfunc.multithreadsettext(txttimerem, clscommonfunc.getformattedtime(tsremtime)); } public static void multithreadsettext(textbox txtbox, string text) { if (txtbox.invokerequired) { txtbox.invoke((methodinvoker)delegate { multithreadsettext(txtbox, text); }); } else { txtbox.text = text; txtbox.refresh(); } } and error this:
source :: mscorlib error :: 6/5/2012 8:51:28 error description : thread being aborted. stack trace: @ system.threading.waithandle.waitonenative(safewaithandle waithandle, uint32 millisecondstimeout, boolean hasthreadaffinity, boolean exitcontext) @ system.threading.waithandle.waitone(int64 timeout, boolean exitcontext) @ system.threading.waithandle.waitone(int32 millisecondstimeout, boolean exitcontext) @ system.windows.forms.control.waitforwaithandle(waithandle waithandle) @ system.windows.forms.control.marshaledinvoke(control caller, delegate method, object[] args, boolean synchronous) @ system.windows.forms.control.invoke(delegate method, object[] args) @ system.windows.forms.control.invoke(delegate method) @ se5.clscommonfunc.multithreadsettext(textbox txtbox, string text) i not able recognize exact problem.
you exception waiting return invoke call.
try changing
txtbox.invoke((methodinvoker)delegate { multithreadsettext(txtbox, text); }); to
txtbox.begininvoke((methodinvoker)delegate { multithreadsettext(txtbox, text); });
Comments
Post a Comment