473,326 Members | 2,175 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,326 software developers and data experts.

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?
Jun 27 '08 #1
1 899
Curious <fi********@yahoo.comwrote:
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:
<snip>
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?
There's no such thing as a thread "level". There are just threads -
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 - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Jun 27 '08 #2

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

Similar topics

7
by: Mike | last post by:
So, I've been trying to do "MyFirstVBWebApp" and I am hitting numerous roadblocks. After much google'ing, here is what I have done (XP Pro SP1, IIS 5.1) 1. Uninstalled IIS 2. renamed the...
5
by: Nick | last post by:
Hi there, This one is really doing my head in, I am attempting to start a thread using the following code, -------------------- Public Sub start() cTrdImportThread = New...
37
by: ales | last post by:
Hello, I have a problem with creation of new thread. The method .Start() of newly created thread delays current thread for 0 - 1 second. Cpu while delay occurs is about 5%. Any idea? Here...
0
by: Yue Fei | last post by:
I have a multi thread python code, threads can start immediately if I run on command line, but I can get them started right the way if I call the same code from C/C++. test code like this: from...
0
by: Vinod Sadanandan | last post by:
Fast-Start Failover An Overview In Dataguard Environment ============================================================================= This article describes the automatic fast start failover...
14
by: shark | last post by:
Hi, Does Form.ShowDialog() start new thread ? If yes how is solved cross-thread operations? Thx
7
by: Brent | last post by:
Page1.aspx calls Page2.aspx like this: ---------------- Server.Execute("Page2.aspx"); --------------- Page2.aspx's Page_Load event calls a function, getMsgs().This function runs normally...
3
by: =?Utf-8?B?SlQ=?= | last post by:
If I call Thread.Start am I guaranteed that thread will be running before the call from Thread.Start returns? i.e. //Doing Something on main thread Thread.Start(NewThreadWork);...
1
by: x9990860 | last post by:
Cross-thread operation not valid: Control 'Form1' accessed from a thread other than the thread it was created on. using System; using System.Collections.Generic; using System.ComponentModel;...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.