[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

Debugger running open loop in server...

Bob Rundle

7/16/2004 11:58:00 AM

I have a server which exposes a tree of remote objects. The server seems to
be working fine if I run without the debugger. If I run in the debugger,
the CPU goes to 100% the first time I access the object from the client.

I've tracked the problem down to this bit of code in the main...

[STAThread]
static void Main(string[] args)
{
simulationresources = new joaSimulationResourcesImp();
simulationresources.Register();
#if false
Thread.CurrentThread.Suspend();
#else
Console.WriteLine("Return ends server.\n");
Console.ReadLine();
#endif
}

If I change the Suspend() call to the Console.ReadLine() then the debugger
no longer has a problem. (I also changed the project settings from Windows
Application to Console Application).

It's very curious to me that the Suspend() call gives the debugger problems.
Clearly suspending the main thread is the proper thing to do for the
deployed server (which will be deployed as a Windows service). Or am I
wrong on this point?

Regards,
Bob Rundle






2 Answers

Sunny

7/16/2004 1:52:00 PM

0

Why do you need to suspend the main thread? This is not a good idea. If
you need to make the thread to wait for something, use ManualResetEvent
or AutoResetEvent.

Sunny


In article <ux84owyaEHA.996@TK2MSFTNGP12.phx.gbl>, rundle@rundle.com
says...
> I have a server which exposes a tree of remote objects. The server seems to
> be working fine if I run without the debugger. If I run in the debugger,
> the CPU goes to 100% the first time I access the object from the client.
>
> I''ve tracked the problem down to this bit of code in the main...
>
> [STAThread]
> static void Main(string[] args)
> {
> simulationresources = new joaSimulationResourcesImp();
> simulationresources.Register();
> #if false
> Thread.CurrentThread.Suspend();
> #else
> Console.WriteLine("Return ends server.\n");
> Console.ReadLine();
> #endif
> }
>
> If I change the Suspend() call to the Console.ReadLine() then the debugger
> no longer has a problem. (I also changed the project settings from Windows
> Application to Console Application).
>
> It''s very curious to me that the Suspend() call gives the debugger problems.
> Clearly suspending the main thread is the proper thing to do for the
> deployed server (which will be deployed as a Windows service). Or am I
> wrong on this point?
>
> Regards,
> Bob Rundle
>
>
>
>
>
>
>

Bob Rundle

7/16/2004 2:10:00 PM

0

Ok...I''m using Sleep(Timeout.Infinite) now and the debugger seems to handle
this OK and this will be fine for the Debug build. In the release mode code
the ServiceBase.Run() handles the main thread. So this is all fine.

Bob Rundle


"Sunny" <sunny@newsgroups.nospam> wrote in message
news:eN5BCwzaEHA.1652@TK2MSFTNGP09.phx.gbl...
> Why do you need to suspend the main thread? This is not a good idea. If
> you need to make the thread to wait for something, use ManualResetEvent
> or AutoResetEvent.
>
> Sunny
>
>
> In article <ux84owyaEHA.996@TK2MSFTNGP12.phx.gbl>, rundle@rundle.com
> says...
> > I have a server which exposes a tree of remote objects. The server
seems to
> > be working fine if I run without the debugger. If I run in the
debugger,
> > the CPU goes to 100% the first time I access the object from the client.
> >
> > I''ve tracked the problem down to this bit of code in the main...
> >
> > [STAThread]
> > static void Main(string[] args)
> > {
> > simulationresources = new joaSimulationResourcesImp();
> > simulationresources.Register();
> > #if false
> > Thread.CurrentThread.Suspend();
> > #else
> > Console.WriteLine("Return ends server.\n");
> > Console.ReadLine();
> > #endif
> > }
> >
> > If I change the Suspend() call to the Console.ReadLine() then the
debugger
> > no longer has a problem. (I also changed the project settings from
Windows
> > Application to Console Application).
> >
> > It''s very curious to me that the Suspend() call gives the debugger
problems.
> > Clearly suspending the main thread is the proper thing to do for the
> > deployed server (which will be deployed as a Windows service). Or am I
> > wrong on this point?
> >
> > Regards,
> > Bob Rundle
> >
> >
> >
> >
> >
> >
> >