multithreading - Restarting a thread in .NET (using C#) -


I am looking for a way to restart a thread that has been stopped by abort ().

Public Partial Class Microgram: Form {Personal Thread MyThread = New Thread (MyFunction); Private Systems Windows.form. Button startStopBtn = new system Windows.form. button (); Public MyProgram () {MyThread.Start (); StartStopBtn + = new event handler (desktop); StartStopBtn.Text = "Stop"; } Private Static Zero My Function () {// Something to do} Private Zero doStop (Object Sender, EventArgs e) {MyThread.Abort (); StartStopBtn - = new event heredoll (desktop); StartStopBtn + = New Event Handler (Dustart); StartStopBtn.Text = "Start"; } Private Zero doStart (Object Sender, EventArgs e) {MyThread.Start (); // & lt; & Lt; Error thrown when clicking on button to start another STARTBtn - = new event; Yesler (Dustart); StartStopBtn + = new event handler (desktop); StartStopBtn.Text = "Stop"; }}

Any ideas?

Just add MyThread = new MyThread.Start () doStart before calling Thread (MyFunction) (), Do not make the thread out of its way, the place considered for the announcements.

Edit: Please note that threads are threaded with thread. Assistant () can be very dangerous. You should try to complete pure multithreading, such as the grupo has been described in your post.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -