Threading suspend/resume issues

... but they're exactly what I want to do!

Page 1 of 1

3 Replies - 5994 Views - Last Post: 07 November 2008 - 10:11 AM Rate Topic: -----

#1 ragingben  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 170
  • View blog
  • Posts: 637
  • Joined: 07-October 08

Threading suspend/resume issues

Post icon  Posted 07 November 2008 - 07:13 AM

Hi everyone I'm having issues with threading. Basically what I want to do is have 2 threads - one for UI and one for calculations, and have the calculations thread suspend on an event, and then resume on another event.

So I used the Thread.Suspend() and Thread.Resume() methods... they work fine for what I want as far as I can tell - but Visual Studio pops up with:

'System.Threading.Thread.Resume()' is obsolete: 'Thread.Resume has been deprecated. Please use other classes in System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources.

ARGH!!!

I want do do this properlly - does anyone know the correct replecements? Because I could use a ManualResetEvent but I dont want to have to keep checking on the calculation thread!

Thanks in advance

Is This A Good Question/Topic? 0
  • +

Replies To: Threading suspend/resume issues

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1632
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Threading suspend/resume issues

Posted 07 November 2008 - 09:12 AM

I personally would stay away from using threads, but thats just me. And if you do use them you dont need one for the GUI, it has its own thread once the application starts. If you create a thread to manipulate the GUI then you have to use delegates to marshal the call onto the thread that created the GUI elements as you cannot access them from a separate thread without it (and you can technically do that from the thread that does the calculations.

Here's a tutorial on using delegates, and one on cross thread communication, which uses a delegate. I would think about using a BackgroundWorker for what you're looking for.

If you're dead set on using threads Peter Richie has a good article on using them the right way.

Hope this helps :)
Was This Post Helpful? 0
  • +
  • -

#3 ragingben  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 170
  • View blog
  • Posts: 637
  • Joined: 07-October 08

Re: Threading suspend/resume issues

Posted 07 November 2008 - 10:10 AM

Thanks a lot, that helps loads and I now have a background worker doing its thang!!!
Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1632
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Threading suspend/resume issues

Posted 07 November 2008 - 10:11 AM

Glad I could help. Someday you will be a BackgroundWorker ninja :)
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1