This is the error that I get when trying to raise the event.
This remoting proxy has no channel sink which means either the server has no registered server channels that are listening, or this application has no suitable client channel to talk to the server.
"Dan Cimpoiesu" <da**********@g mx.net> wrote in message news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Thanks Anders
But I still can't manage to make it work.
Still nothing happens on client when I raise the event from server.
Here are some snippets of my code.
//
//on server side
//
public class RemotingServer : MarshalByRefObj ect
{
private Int32 current;
private Int32 total;
public event PrepareProgress Handler PrepareProgress ;
//this is a Zip Control event handler
protected void OnZipProgress(D artZip.ZipStatu sConstants constants,DartZ ip.File file,
Int32 x,Int32 fileBytes,Int32 totalBytes)
{
current=totalBy tes;
total=file.Size ;
try
{
(new Thread(new ThreadStart(OnP repareProgress) )).Start();
}
catch
{
log.WriteLine(" OnZipProgress() - Cannot start a new thread");
}
}
protected virtual void OnPrepareProgre ss()
{
try
{
if (PrepareProgres s!=null)
{
PrepareProgress (this,new PrepareProgress Args(current,to tal));
}
}
catch
{
log.WriteLine(" OnPrepareProgre ss - Cannot raise the event");
}
}
}
public class PrepareProgress Args : EventArgs
{
private Int64 _current;
private Int64 _total;
public Int64 Current
{
get {return _current;}
}
public Int64 Total
{
get {return _total;}
}
public PrepareProgress Args(Int64 current,Int64 total)
{
_current=curren t;
_total=total;
}
}
public delegate void PrepareProgress Handler(Object source,PrepareP rogressArgs args);
//
//on client side
//
srv=(RemotingSe rver)Activator. GetObject(typeo f(RemotingServe r),Settings..Se rverName);
srv.PrepareProg ress+=new Remoting.Prepar eProgressHandle r(srv_PreparePr ogress);
public void srv_PrepareProg ress(Object sender,PrepareP rogressArgs args)
{
pbrMain.Maximum =(Int32)args.To tal;
pbrMain.Value=( Int32)args.Curr ent;
Application.DoE vents();
}
"Anders Forsgren" <an************ *@nospam.csce.s e> wrote in message news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
On the server side (marshalByRef side) just raise the event in a new thread.
Server :
public event EventHandler MyServerEvent
private void RaiseServerEven t()
{
new Thread( new ThreadStart(DoM yServerEvent).S tart();
}
public void DoMyServerEvent ()
{
if (MyServerEvent != null)
MyServerEvent(t his, new EventArgs());
}
The client can subscribe to this event in the usual way. I Don't know if
there is a more elegant way of doing remote/multithreaded events, but this
works. Hope it helps.
/Anders
"Dan Cimpoiesu" <da**********@g mx.net> skrev i meddelandet
news:uI******** ******@tk2msftn gp13.phx.gbl... I have a remoting object, derived from MarshalByRefCom ponent, that I
instantiate on the client side, with Activator.GetOb ject.
Can I receive events fired on the server, on the client?
How?