Connecting Tech Pros Worldwide Forums | Help | Site Map

How to resume thread?

TOMERDR
Guest
 
Posts: n/a
#1: Nov 17 '05

Hi,
I have a sync manager class which span a thread which run a tight
loop(Sync function)

I would like that after the loop is finished,every 5 minutes the
thread will run again
I want also the ability to stop the thread in the middle of the loop

Is it ok to just use a timer in the SyncManager class?

Thanks in advance


public class SyncManager
{
Thread m_workerThread;

public SyncManager()
{

}


/// <summary>
///
/// </summary>
public Stop()
{

}



/// <summary>
///
/// </summary>
public void Start()
{
m_workerThread= new Thread(new ThreadStart(Sync));
m_workerThread.Name = "Sync";
m_workerThread.IsBackground = true;
m_workerThread.Start();
}

/// <summary>
///
/// </summary>
public void Sync()
{

}


Johann Blake
Guest
 
Posts: n/a
#2: Nov 17 '05

re: How to resume thread?


Are you talking about a Timer control? You don't need a form to create
a Timer class. So there is no real reason why you cannot use a Timer
control.

HTH,
Johann Blake

Nicholas Paldino [.NET/C# MVP]
Guest
 
Posts: n/a
#3: Nov 17 '05

re: How to resume thread?


TOMERDR,

You could use a timer which will re-start the process five minutes after
it ends. As for the ability to stop your loop, you could have a flag that
is set on your SyncManager class (or a method), which will cancel the loop.
This will set a flag that is checked in your thread (make sure you lock
access to the flag), and if the flag is true, it stops processing the loop.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com

"TOMERDR" <tomerdr@hotmail.com> wrote in message
news:1121688737.947693.212110@o13g2000cwo.googlegr oups.com...[color=blue]
>
> Hi,
> I have a sync manager class which span a thread which run a tight
> loop(Sync function)
>
> I would like that after the loop is finished,every 5 minutes the
> thread will run again
> I want also the ability to stop the thread in the middle of the loop
>
> Is it ok to just use a timer in the SyncManager class?
>
> Thanks in advance
>
>
> public class SyncManager
> {
> Thread m_workerThread;
>
> public SyncManager()
> {
>
> }
>
>
> /// <summary>
> ///
> /// </summary>
> public Stop()
> {
>
> }
>
>
>
> /// <summary>
> ///
> /// </summary>
> public void Start()
> {
> m_workerThread= new Thread(new ThreadStart(Sync));
> m_workerThread.Name = "Sync";
> m_workerThread.IsBackground = true;
> m_workerThread.Start();
> }
>
> /// <summary>
> ///
> /// </summary>
> public void Sync()
> {
>
> }
>[/color]


Closed Thread