Re: Problem in running .Net Service on a Quad Processor



<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.

.



Relevant Pages

  • Re: Problem in running .Net Service on a Quad Processor
    ... stringargs) ... AppDomain curr = AppDomain.CurrentDomain; ... typeof(ServiceRuntime).Assembly.GetName.FullName, ... Forget about the hw configuration and concentrate on the OnStart method, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Problem in running .Net Service on a Quad Processor
    ... The OnStart method calls the Start method. ... typeof(ServiceRuntime).FullName ... You should add tracing and logging to your methods, your exception handling should also ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C# Service Terminating Itself
    ... > In SDK terms, ... > RegisterServiceCtrlHandlerEx() to register a callback for communication ... > with the SCM. ... When OnStart returns normally, "StartSuccessful" is written to the EventLog, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Windows Service Starts and Immediately Stops
    ... The OnStart is suppose to be short, the solution to your problem execute ... protected override void OnStart(stringargs) ... It also works in release mode on my dev machine. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Problem in running .Net Service on a Quad Processor
    ... But what baffles me is that on my machine it does not give this timeout ... This is because your OnStart method did not return in a timely fashion, ... called the SCM waits for a maximum of 30 seconds for it to return, ...
    (microsoft.public.dotnet.languages.csharp)

Loading