C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Timer in threading


Posted Date: 06 Aug 2008    Resource Type: Code Snippets    Category: Threading

Posted By: D.Jeya kumar(JK)       Member Level: Diamond
Rating:     Points: 5



This code sample creates a time and starts it in a new thread. To disable the thread we use the same timer as shown in the example.



'To create the timer for the threading part
Public KeepAliveDelegate As Threading.TimerCallback
Public KeepAliveTimer As System.Threading.Timer
'end

KeepAliveDelegate = AddressOf KeepAliveTimerHandler

'To start the threading timer.
KeepAliveTimer = New System.Threading.Timer(KeepAliveDelegate, Nothing, 100, 100)
KeepAliveTimer.Change(100, 100)

Private Sub KeepAliveTimerHandler(ByVal state As Object)
'Add code to run until the thread is stoped
End sub

'To stop the thread or to disable the thread
KeepAliveTimer.Change(0, System.Threading.Timeout.Infinite)

'to restrat the thread again using the below code
KeepAliveTimer = New System.Threading.Timer(KeepAliveDelegate, Nothing, 0, 100)





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Timer in threading  .  Threading with timers  .  Threading using Timers  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: This C# code snippet checks the state of the current thread by examining the ThreadState property of
Previous Resource: BackGroundWorker Control
Return to Discussion Resource Index
Post New Resource
Category: Threading


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use