Alex Rivera | Logout

How to stop System.Threading.Timer in callback method

Asked 2012-08-13T16:33:23.543
10

How can I stop System.Threading.Timer in it's call back method. I referenced MSDN, but couldn't find anything useful. Please help.

Edit
Report

1 Answer

2

Try this:

If you want you could let timer continue firing the callback method and include the code below

private void CreatorLoop(object state)  
 { 
   if (Monitor.TryEnter(lockObject) 
   { 
     try 
     { 
       // Work here 
     } 
     finally 
     { 
       Monitor.Exit(lockObject); 
     } 
   } 
 } 

check out this link too:

Stopping timer in its callback method

answered 2012-08-13T16:38:52.977

Your Answer