/// <summary> /// CIPCの状態を送信する /// </summary> public void Tcp_Send() { try { List <TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Client> clientlist = new List <TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Client>(); List <TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Connection> connectionlist = new List <TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Connection>(); if (this.RHS.List_RemoteHost.Count > 0) { foreach (var count in this.RHS.List_RemoteHost) { TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Client.Mode mode; if (count.Connection_Mode == ConnectionState.Sender) { mode = TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Client.Mode.Sender; } else if (count.Connection_Mode == ConnectionState.Receiver) { mode = TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Client.Mode.Receiver; } else { mode = TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Client.Mode.Default; } clientlist.Add(new TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Client(count.ID, count.Name, int.Parse(count.remotePort), count.remoteIP, count.Fps, mode)); } } if (this.DCS.List_dataconnection.Count > 0) { foreach (var count in this.DCS.List_dataconnection) { connectionlist.Add(new TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo.Connection(count.SENDER.ID, count.RECEIVER.ID)); } } bool IsSyncConnect = false; System.Windows.Threading.DispatcherOperation DO = this.mainwindow.Dispatcher.BeginInvoke(new Action(() => { IsSyncConnect = this.mainwindow.CheckBox_IsSyncReceived.IsChecked == true ? true : false; })); DO.Wait(); TerminalConnectionSettings.ServerProtocols.ReportInfo reportinfo = new TerminalConnectionSettings.ServerProtocols.ReportInfo(new TerminalConnectionSettings.ServerProtocols.ReportInfo.CIPCInfo(clientlist, connectionlist, IsSyncConnect)); this.send.stringData = reportinfo.Data; this.networkstream.Write(this.send.encodedbytes, 0, this.send.encodedbytes.Length); this.debugwindow.DebugLog = "[TerminalConnection]送信:" + this.send.stringData; } catch (Exception ex) { this.debugwindow.DebugLog = "[" + this + "]" + ex.Message; } }
private void DoRaiseCollectionChanged(NotifyCollectionChangedEventHandler handler, NotifyCollectionChangedEventArgs ev) { //var lastOp = _lastOp; //while (true) { _lastOp?.Wait(); //if (object.ReferenceEquals(System.Threading.Interlocked.CompareExchange(ref _lastOp, null, lastOp), lastOp)) { _lastOp = System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.DataBind, handler, this, ev); return; //} //lastOp = _lastOp; //} }
public static void DumpLog() { LastOperation.Wait(); TextRange tr = new TextRange(_Instance.Console.Document.ContentStart, _Instance.Console.Document.ContentEnd); string dir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs"); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } IEnumerable <string> logFiles = Directory.EnumerateFiles(dir); if (logFiles.Count() >= 10) { foreach (string file in logFiles) { File.Delete(Path.Combine(dir, file)); } } File.WriteAllText(Path.Combine(dir, $"{DateTime.Now:dd\\-M\\-yyyy}_{DateTime.Now.GetHashCode()}_DEBUG-HunterPie.log"), tr.Text); }