![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Start a new thread from an existing thread, which was started from atimer Hi, It turns out that I must start a new thread from an existing thread that was started from a timer. In other words, the relations are described in the code below: void Main() { mTimer = new Timer(new TimerCallback(CheckHistoricalData), null, 15000, 15000); } // Callback for the timer void CheckHistoricalData(object state) { ThreadPool.QueueUserWorkItem(new WaitCallback(GetCashByList), null); // Code omitted here } void GetCashByList(object o) { // Code omitted here if (cashR.CashForToday <= cashR.LowerBound) { // Start a new thread to display messagebox // Pass both list and cash for sector ThreadPool.QueueUserWorkItem(new WaitCallback (ShowSectorCashMessage), cashR); } } I'm concerned that my program may crash because each thread is at a different level and there are so many levels of threads. Anyone can advice me if this is safe? Is there anything I can do to make the program robust? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Start a new thread from an existing thread, which was started from a timer Curious <fir5tsight@xxxxxx> wrote: Quote: > It turns out that I must start a new thread from an existing thread > that was started from a timer. > > In other words, the relations are described in the code below: Quote: > I'm concerned that my program may crash because each thread is at a > different level and there are so many levels of threads. Anyone can > advice me if this is safe? Is there anything I can do to make the > program robust? admittedly there are threads in the thread-pool and threads which aren't in the thread-pool, but I see nothing in the code you've posted which will crash the system. You should look at whether you *really* need all those threads though, just for the sake of understanding the complexity of the system. -- Jon Skeet - <skeet@xxxxxx> Web site: http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet C# in Depth: http://csharpindepth.com |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| How do the current thread get thread notification of OS intruption | .NET General | |||
| thread | General Discussion | |||
| start System.Threading.Thread | PowerShell | |||
| Where is my thread? | Vista music pictures video | |||