Re: Problem in running .Net Service on a Quad Processor
- From: "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx>
- Date: Thu, 11 Jan 2007 19:19:42 +0100
<sunil@xxxxxxxxxxxxxxx> wrote in message news:1168525651.387095.126580@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi Willy,
The following is the code snippet that my Service Executes onStart
public static void Start( bool isConsole, string[] args )
{
try
{
AppDomain curr = AppDomain.CurrentDomain;
AppDomainSetup info = new AppDomainSetup();
info.ApplicationBase = curr.BaseDirectory;
info.ApplicationName = typeof( ServiceRuntime ).FullName;
info.ApplicationBase = curr.BaseDirectory;
info.ConfigurationFile =
curr.SetupInformation.ConfigurationFile.Replace( ".CmdLine.", "." );
info.ShadowCopyFiles = "false";
_domain = AppDomain.CreateDomain( info.ApplicationName,
curr.Evidence, info );
_runtime = (ServiceRuntime)_domain.CreateInstanceAndUnwrap(
typeof( ServiceRuntime ).Assembly.GetName().FullName,
typeof( ServiceRuntime ).FullName
);
_runtime.Init( isConsole );
_runtime._Start( args );
}
catch( Exception e )
{
throw;
}
}
In _Start I am creating a few threads...
for( int i = 0; i < nThreads; i++ )
{
t = new Thread ( new ThreadStart ( this.ThreadProc ) ) ;
t.Name = "Job Processor Engine Thread(" + i.ToString() + ")";
t.Start () ;
this.threads.Add ( t ) ;
}
and doing some db activites....
But why is this failing on a QuadProc machine and working well on other
machines? Is there some setting I need to tune/change? Please help...
Thanks & regards
Sunil
Well I can't tell, first I asked to post your "OnStart()" code, instead you post Start, it's not clear at all how you call this from OnStart().
It looks like you don't run this "Start" in another thread, that means that OnStart only returns to the SCM when Start returns. Now, if you DB activity takes more than 30 seconds (possibly a connection cannot be made because your connection parameters aren't valid or the security context is invalid etc...), the SCM will get nervous and kill the "OnStart" thread and bail out. Keep in mind that OnStart runs on an SCM thread not on a CLR thread, the SCM is the master of the game here, you have to obey his rules ;-)
So, I would suggest you run this "Start" method on a separate background thread from OnStart and return from OnStart when the thread has started. Also, you should code more defensively, You should add tracing and logging to your methods, your exception handling should also largely be improved.
Willy.
.
- Follow-Ups:
- References:
- Problem in running .Net Service on a Quad Processor
- From: sunil
- Re: Problem in running .Net Service on a Quad Processor
- From: Willy Denoyette [MVP]
- Re: Problem in running .Net Service on a Quad Processor
- From: sunil
- Re: Problem in running .Net Service on a Quad Processor
- From: Willy Denoyette [MVP]
- Re: Problem in running .Net Service on a Quad Processor
- From: sunil
- Problem in running .Net Service on a Quad Processor
- Prev by Date: Re: Inheriting Image/Bitmap
- Next by Date: Re: Start up directory for my dll
- Previous by thread: Re: Problem in running .Net Service on a Quad Processor
- Next by thread: Re: Problem in running .Net Service on a Quad Processor
- Index(es):
Relevant Pages
|
Loading