473,395 Members | 1,919 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,395 software developers and data experts.

how to restart a thread

Hi,
I want to restart a thread after same variable value in
the thread reaches 100 in c# . How can I do. Please
suggest me any solution
Nov 15 '05 #1
3 10436
Hi Kranthis:

What I would do is have the thread that is counting be a child thread. When
it is completed processing the 100 things it does, have it die (exit the
thread).
In your parent thread, monitor your child thread's status. (Thread.IsAlive
method) If it is non running, you know it finished. At that point, you would
restart it (Thread.Start())
The tricky part will be the monitoring in the parent thread. This you will
need to do without cause the parent thread to stop responding (like looping
forever until child thread is dead). My suggestion would be to read up on
Callbacks, where the child can post a callback to the parent telling it that
it has completed. Parent can then start new thread. Some other suggestions:
using a ThreadPool, or using a Mutex/WaitFor combination in parent thread.

Hope this helps, I know not very detailed, to early in the AM to think:-)

S

"Kranthis" <an*******@discussions.microsoft.com> wrote in message
news:11*****************************@phx.gbl...
Hi,
I want to restart a thread after same variable value in
the thread reaches 100 in c# . How can I do. Please
suggest me any solution

Nov 15 '05 #2
When value reaches 100 you can spawn new thread from the current with the
same thread function

"Kranthis" <an*******@discussions.microsoft.com> wrote in message
news:11*****************************@phx.gbl...
Hi,
I want to restart a thread after same variable value in
the thread reaches 100 in c# . How can I do. Please
suggest me any solution

Nov 15 '05 #3
Don't use threads for this, use asynch. delegates or workerthreads from the
threadpool. Check the MSDN doc's for samples.
Willy.

"Kranthis" <an*******@discussions.microsoft.com> wrote in message
news:11*****************************@phx.gbl...
Hi,
I want to restart a thread after same variable value in
the thread reaches 100 in c# . How can I do. Please
suggest me any solution

Nov 15 '05 #4

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

Similar topics

1
by: localhost | last post by:
In the Application_OnStart, I make some data calls and place the results in the HTTP cache. Sometimes, the database is not available when the application starts up, so I want to sleep for 20...
2
by: Chris Langston | last post by:
I have a Web Server running IIS 5 or 6 on Windows 2K and Windows 2003 Server that is experiencing strange shutdown problems. We are using ASP.NET v1.1 and our application is written in VB.NET ...
14
by: iceman | last post by:
Hello, I have a windows service. I want to restart it after every 24 hour. Is it possible to restart the service programmatically(from the service itself) using the sercvice controller object?...
6
by: Leonardo Curros | last post by:
Hello, I would like to know what's the best way to restart one service. I would like to do it from the service itself. Is this possible? I try it with ServiceController.stop()...
1
by: Mamatha | last post by:
Hi I have one doubt regarding threads in my application. If i aborted one thread ,then i want to restart the same thread again.How can i restart that one. Is it possible to restart a thred...
22
by: Brett | last post by:
I have a second thread, t2, that errors out and will stop. It's status is then "Stopped". I try to start t2 from thread 1, t1, by checking If t2.threadstate = "Stopped" Then t2.start() ...
5
by: juky | last post by:
Hi all, I have 3 running threads chencking for something in my application. Based on that I need to stop some of them safely wait for something else and restart. Sleep is not good in my case...
1
by: many_years_after | last post by:
class mythread(threading.Thread): def __init__(self, threadname): threading.Thread.__init__(self, name = threadname) def run(self): print 'i am running' print 'i quit run()' thread =...
5
by: David Thielen | last post by:
Hi; We keep having to restart IIS after ASP.NET kills it. Below is what we have in the event log. Any idea what the problem is? thanks - dave Event code: 3003 Event message: A validation...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.