开发者

C# Process.Start, Thread.IsBackGround, BackgroundWorker and .Net.Remoting

I need an advice because I'm "locked"...

I have a client-server application using .NetRemoting between the clie开发者_如何学Cnt process and the server one.

Server process raises events to the client calling a method.

Then, the client uses a BackGroundWorker to transmit values to User Interface.

Usualy, the server is already running when the client is launched.

- When BackGroundWorker.DoWork() is called, Thread.CurrentThread.IsBackground equals True

- In BackGroundWorker_RunWorkerCompleted event, Thread.CurrentThread.IsBackground equals False

But, if, during the client is loading (.exe is opening), it needs to open (with Process.Start()) the Server process (.exe) before it connects

then, in BackGroundWorker_RunWorkerCompleted, Thread.CurrentThread.IsBackground is still equal to True and UI can not be changed in this thread.

In that case, I need to open an other client (connecting to the same server) to have a good behavior.

What could be the difference between these two situations ?

Thanks.


What you should have:

Client:
--UI thread: starts BGWorker and runs BackgroundWorker.RunWorkerCompleted
--Backgroundthread: runs BackgroundWorker.DoWork, communicates with server

<->

Server: communicates with client

Why isn't your server already running when your client is starting? + Why use remoting if they're running on the same machine??


I've found the (a) solution : In the client startup :

lChannelTCP = new TcpChannel(lProps, provider, providerSrv);
ChannelServices.RegisterChannel(lChannelTCP, false);

or (haven't test wich one)

RemotingConfiguration.ApplicationName = "EDV";

has to be set before Server process is started !

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜