private void irt_ConnectionLost(object sender, EventArgs e) { irt.IRReceive -= new IRTransServer.IRReceiveEventHandler(IRReceived); irt.ConnectionLost -= new IRTransServer.ConnectionLostEventHandler(irt_ConnectionLost); irt = null; this.ReestablishConnection(); }
/* Function: IRTRANS_Init() * Parameters: None * Description: checks connection to IRTrans server application availability */ public Boolean IRTRANS_Init() { try { irtObj = null; // Reset the connect whenever user refresh it irtObj = new IRTransServer("localhost"); // connect to IR trans server if (irtObj != null) { irtObj.StartAsnycReceiver(); bIsIRTransConnected = true; } else { bIsIRTransConnected = false; } } catch (Exception) { System.Diagnostics.Process[] processName = System.Diagnostics.Process.GetProcessesByName("IRServer"); bIsIRTransConnected = false; } return(bIsIRTransConnected); }
protected override bool ConnectProviderSpecific() { try { if (Monitor.TryEnter(lockObject)) { if (irt == null) { irt = new IRTransServer(base.targetEndPoint.Address.ToString()); irt.StartAsnycReceiver(); irt.IRReceive += new IRTransServer.IRReceiveEventHandler(IRReceived); irt.ConnectionLost += new IRTransServer.ConnectionLostEventHandler(irt_ConnectionLost); } Monitor.Exit(lockObject); return(true); } return(false); } catch { Monitor.Exit(lockObject); return(false); } }