private async void NotifyConnectStateChanged(ConnectStateArgs connectStateArgs, string error) { if (connectStateArgs.ConnectState == ConnectState.Faild) { IsConnected = false; lock (lockConnectStatus) { //isStart = false; if (client != null) { client.Close(); } } if (taskReceive != null) { await taskReceive; } //if (taskQueue != null) await taskQueue; } connectStateArgs.IsStop = isStop; connectStateArgs.Error = error; if (ConnectStateChanged != null) { var handlers = ConnectStateChanged.GetInvocationList(); if (handlers != null) { foreach (EventHandler <ConnectStateArgs> item in handlers) { item.BeginInvoke(this, connectStateArgs, null, null); } } } }
private void ConnectStateChange() { if (ConnectStateChanged != null) { foreach (EventHandler <ConnectEventArgs> deleg in ConnectStateChanged.GetInvocationList()) { deleg.BeginInvoke(this, new ConnectEventArgs() { Connect = Connected }, null, null); } } }