473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to resume thread?


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()
{

}

Nov 17 '05 #1
2 1552
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

Nov 17 '05 #2
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]
- mv*@spam.guard.caspershouse.com

"TOMERDR" <to*****@hotmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...

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()
{

}

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Keith Langer | last post by:
I have an application which consists of a main work thread and multiple threads which each maintain a TCP socket. When a configuration change occurs, all activity on the socket threads must be...
2
by: SpookyET | last post by:
How do you pause and resume some work without using Thread.Suspend and Thread.Resume since they are deprecated in .NET 2.0?
2
by: juky | last post by:
Hi all, I have a loop in the thread checking for a particular service status, whenever the status changes to "stopped" a RaiseEvent is generated by thread and another function runs. At the same...
17
by: Benny Raymond | last post by:
I have a thread that sleeps for 5 minutes once it's finished running a method and then it repeats itself if it's supposed to (bool = true). Prior to 2.0 I was able to resume the thread after...
4
by: Tam | last post by:
Hi group, Just downloaded the new Visual Studio 2005 (well new to me seeing as i was previously using 2003). My problem/question is that my Thread.Resume statements in an application I've...
6
by: Buddy Home | last post by:
Hello, I want to understand whats the best way to write code to replace Thread.Suspend, Thread.Resume and Thread.Abort. I have lots of code calling these existing methods and want to minimize...
4
by: wanwan | last post by:
I'm using Microsoft Visual Studio 2005 in multithreading, I want to be able to pause and resume a thread. I see that suspend and resume are deprecated. So what can I use instead.
4
by: fAnSKyer/C# newbie | last post by:
I am using winmm.dll and I found that I can't just suspend it and resume it? What should I do? Any better idea? Should I use thread? and thread.suspend will work? Thanks
3
by: =?Utf-8?B?TWFyayBDaGFubmluZw==?= | last post by:
I have a code which registers all threads with a thread dump class. At intervals this thread dump class will dump the stack trace of all threads. As calling StackTrace(threadtoDump) from a...
1
by: Mike Fellows | last post by:
Having not used threads for such a long time in vb.net I have found myself in need of them I have a thread that runs and retirieves live data from a SQL database, this is running fine and has...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.