473,399 Members | 3,603 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,399 software developers and data experts.

ThreadStart not called on some servers

Hi all

I'm stuck with a problem and hope someone can provide some hints on
what I'm doing wrong.

All I want to do ist start a thread which will sleep until a specified
time and then wake up and do some stuff. (see reduced-to-the-max
sample code below)
The stange thing is, it works on my developer machine (Win XP) and on a
virtual machine (Win2003 Server) I use to test, but on the "real"
server (also Win2003) RunInNewThread ist never called, also the
ThreadState is "running".
There are no exceptions, no entries in the event log.. nothing.

All machines have .NET 2.0 installed. The two working systems are
running with the default-configuration. On the target server I'm not so
sure about that, but I need to tell the administrator where to start
searching since he knows even less than I do.

Hope someone can help me on this.
TIA
Stefan

private void Test_StartThread()
{
try
{
DateTime threadStartTime = DateTime.Now.AddSeconds(30.0);
ThreadStart starter = delegate {
TestClass.RunInNewThread(threadStartTime); };
Thread t = new Thread(starter);
t.Start();
Console.Write("Thread state : " + t.ThreadState.ToString());
}
catch(Exception ex)
{
Console.Write("Starting thread falied");
}
}
public class TestClass
{
public static void RunInNewThread(DateTime pStartTime)
{
Console.Write("starting thread to run at " +
pStartTime.ToString());
// in real app, thread will sleep until pStartTime and then do some
stuff
// Thread.Sleep(pStartTime.Subtract(DateTime.Now);
//
// -- do something
}
}

Jul 10 '06 #1
2 1444
Hi Stefan,
All I want to do ist start a thread which will sleep until a specified
time and then wake up and do some stuff.
Is your application a console/windows application, a asp.net
application or a windows service?
I have not had this problem in a windows service and I have never
tried using such thread within IIS, or even within a windows
application so possibly I have no solution for it.

But just to jog your mind a bit, I would also suggest that you consider
following
1) using a Timer instead of sleeping thread.
2) use windows scheduler to invoke this thread / or a this thread
refactored into a console application. You can also consider making it
a MS SQL Server job ( Helpful if you are looking at clustered / failed
over configurations for server side jobs).
Pranshu

Jul 10 '06 #2
Hi Pranshu

thanks for your response. I'm dealing with a ASP.NET application and
since it hosted by another company I do not have priviledges to run
windows apps/services or ti initiate SQL Server jobs.
But I will try the approach with the Timer, I only knew that as a
client-Control and was not aware that it also exists for webapps.

Stefan

pranshu wrote:
Hi Stefan,
All I want to do ist start a thread which will sleep until a specified
time and then wake up and do some stuff.

Is your application a console/windows application, a asp.net
application or a windows service?
I have not had this problem in a windows service and I have never
tried using such thread within IIS, or even within a windows
application so possibly I have no solution for it.

But just to jog your mind a bit, I would also suggest that you consider
following
1) using a Timer instead of sleeping thread.
2) use windows scheduler to invoke this thread / or a this thread
refactored into a console application. You can also consider making it
a MS SQL Server job ( Helpful if you are looking at clustered / failed
over configurations for server side jobs).
Pranshu
Jul 14 '06 #3

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

Similar topics

2
by: Victor Hadianto | last post by:
Hello, Can someone explain to me why are we not allowed to have a parameter on the ThreadStart delegate? Does anyone know the design decision behind this feature? This, IMO, rather annoying when...
2
by: n_o_s_p_a__m | last post by:
I run my multithreaded classes (class library) in a standard exe host, works with no problems; but once hosted in SCM, the threads are not spawned, yet no exceptions are thrown. Is this some kind...
3
by: Maxime | last post by:
Can put a method with parameter in the ThreadStart ? Thread bThread = new Thread(new ThreadStart(Function(Parameter))); // Not Ok why? another way maybe ? Max
4
by: Fernando Rodríguez | last post by:
Hi, ThreadStart doesn't take any parameters. How can I create threads that take parameters? O:-) Thanks
2
by: Martin Høst Normark | last post by:
Hi everyone Has anyone got the least experience in integrating the Digital Signature with an ASP.NET Web Application? Here in Denmark, as I supose in many other countries, they're promoting...
8
by: Claus | last post by:
Hi all, I am new to C#, .NET and Visual Studio but I have been coding professionally for more than 10 years, so I am not a complete newbe :-) At my work we are now in the process of switching...
4
by: Mike P | last post by:
How do you pass your parameters to the method you have specified for the threadstart? System.Threading.ThreadStart thdStart = new System.Threading.ThreadStart(MoveMail(new object { progress,...
1
by: robparr | last post by:
Hello, hopefully someone can help me. I am reading and learning steadily about threading and asynchronous programming, which to me sound like the same thing. At the moment I am not sure what the...
1
by: ktrvnbq02 | last post by:
Hi, I recently came to debug some old code that was causing a StackOverflowException. The code in question makes significant use of recursion and with large data structures it exhausted the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.