Thread.Suspend and Thread.Resume replacments?

G

Grant Merwitz

Hi

I have tried to use a Thread.Suspend in .NET 2.0, and am presented with the
warning message:

Warning 1 'System.Threading.Thread.Suspend()' is obsolete: 'Thread.Suspend
has been deprecated. Please use other classes in System.Threading, such as
Monitor, Mutex, Event, and Semaphore

So., how am i suppossed to pause a thread.
Thread.Suspend works fine, but i don't want to use something thats being
deprecated

Thread.Abort says the same message, so also how do i abort or cancel a
thread

TIA
 
M

Mattias Sjögren

Grant,
So., how am i suppossed to pause a thread.

Why do you want to pause it?

Thread.Abort says the same message, so also how do i abort or cancel a
thread

Ideally you don't, you make it stop doing whatever task it is doing
and return.


Mattias
 
G

Grant Merwitz

Thanks for the answers ... um, were they answers?
I thought i was the one asking the questions here :)

Anyways, i have a process that saves a file across servers.
Depending on the file size, this process can take really long.
I simply wanted to give the user the option to Cancel if it was taking too
long.

So, the user click cancel, and i popup a window confirming this --> Here i
want to pause the thread.
They Click ok --> Here i want to stop the thread.
They Click no --> I resume the thread.

Now, doing some more research, i found out Thread.Suspend and especially
Thread.Abort of TERRIBLE ideas.

So i am going to break the file down to bytes transfer them bit by bit in a
loop.
If a cancel variable is set, i will then delete the progress.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top