Re: Problem in running .Net Service on a Quad Processor
- From: sunil@xxxxxxxxxxxxxxx
- Date: 14 Jan 2007 20:44:30 -0800
Hi Willy,
The OnStart method calls the Start method. I had actually left out the
exception handling as it was not needed to be posted...:-) well I did a
trace of the application and found that the maximum time taken was for
just invoking the _init & the _Start method...
_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 );
After the AppDomain is created and the call to _init takes more than
40sec...I put a trace statement before the function call, in the first
line of the function and at end of the function...
00000007 11.30131397 [2864] JOBServer: Init Call
00000382 41.83827053 [2864] JOBServer: Init Function Start
00001228 71.89844367 [2864] JOBServer: Init Function end
00001229 71.89849695 [2864] JOBServer: Init invoked successfully
00001242 101.93207238 [2864] JOBServer: Begin of ServiceRuntime _Start
00001284 103.17994353 [2864] JOBServer: End of ServiceRuntime _Start
Why is calling an AppDomain function taking such a long time? Is there
some CAS done? It is fast on my Windows XP machine.
Any clues?
Thanks & regards
Sunil
Willy Denoyette [MVP] wrote:
<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:
- Re: Problem in running .Net Service on a Quad Processor
- From: Willy Denoyette [MVP]
- Re: Problem in running .Net Service on a Quad Processor
- 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
- Re: Problem in running .Net Service on a Quad Processor
- From: Willy Denoyette [MVP]
- Problem in running .Net Service on a Quad Processor
- Prev by Date: Re: Using a regular expression to retrieve the text between two parentheses
- Next by Date: Combobox with checked list box.
- 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