0


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

I have a client-server application using .NetRemoting between the client 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.

edid
  • 349
  • 3
  • 8
  • Are you creating the BackgroundWorker on a non-UI thread? See http://stackoverflow.com/questions/2806814/c-backgroundworker-runworkercompleted-event/2806824#2806824 – Justin Mar 17 '11 at 13:17

2 Answers2

0

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

Vincent Vancalbergh
  • 3,267
  • 2
  • 22
  • 25
  • my server is an application server. Clients are WinForm, Web browsers or simple class. You can visit http://edv.edvariables.net for few images but presentation is in french, as well my UI is. Sorry (too much job to translate it). – edid Mar 17 '11 at 14:43
0

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 !

edid
  • 349
  • 3
  • 8