Menu

#1 Fix Cross Threading Exception on successful iso write

open
nobody
None
5
2008-10-03
2008-10-03
Anonymous
No

The function creator_Finished in MainForm.cs (~line 94) raises a cross thread exception by trying to access buttonStartAbort from a different thread than it was created on. There is an easy fix for this; wrap the UI manipulation code in an Invoke statement:

<code>

void creator_Finished( object sender, FinishEventArgs e ) {
MessageBox.Show( e.Message, "Finish", MessageBoxButtons.OK, MessageBoxIcon.Information );
this.Invoke(new EventHandler((o1,e1)=>
{
//avoid cross-thread exception
Console.WriteLine("called from within invoke");
buttonStartAbort.Enabled = true;
buttonStartAbort.Text = "Start";
progressBar.Value = 0;
labelStatus.Text = "Process not started";
}));
}

</code>

Discussion


Log in to post a comment.

MongoDB Logo MongoDB