private static void Main() { //import classes ConnectionManeger connection = new ConnectionManeger(); ThreadManeger thread = new ThreadManeger(); //creates lists for sockets and threads List <Socket> socketArr = new List <Socket>(); List <Thread> threadArr = new List <Thread>(); //start the server TcpListener server = connection.StartServer(); while (true) { //create a socket bound to a thread and add it to te list if a connection is pending if (server.Pending()) { Socket tempSocket = server.AcceptSocket(); socketArr.Add(tempSocket); Thread tempThread = new Thread(() => thread.ThreadReadBytes(tempSocket)); threadArr.Add(tempThread); tempThread.Start(); } } }
private void WindowViewBase_Initialized(object sender, EventArgs e) { this.WindowTitle = base.Title; object appdata = null; if (this.Owner is WindowViewBase) { appdata = (this.Owner as WindowViewBase).viewsCommData.AppData; } else if (this.Owner is RibbonWindowViewBase) { appdata = (this.Owner as RibbonWindowViewBase).viewsCommData.AppData; } if (this.viewsCommData == null) { this.viewsCommData = new ViewsCommon(appdata); this.viewsCommData.Initialize(); } threadmgr = new ThreadManeger(this.viewsCommData.DacConf, this.appLog); threadmgr.Name = this.GetType().Name; threadmgr.OnReceived += new MessageReceiveHandler(OnReceived); ViewBaseCommon.SetConfigToControls(this, this.viewsCommData); functionList.Add(MessageType.ResponseData, this.OnReceivedResponseData); functionList.Add(MessageType.Error, this.OnReveivedError); functionList.Add(MessageType.ResponseStored, this.OnReceivedResponseStored); functionList.Add(MessageType.ResponseWithFree, this.OnReceivedResponseData); functionList.Add(MessageType.ErrorWithFree, this.OnReveivedError); functionList.Add(MessageType.TimerLoop, this.OnReceivedTimer); funckeyInitialize(); }
//private void FrameworkControl_Unloaded(object sender, RoutedEventArgs e) //{ // this.Unloaded -= FrameworkControl_Unloaded; // if (this is UcLabelTwinTextBox || this is UcLabelComboBox) // { // if (this.thmgr != null) // { // thmgr.OnReceived -= new MessageReceiveHandler(OnReceived); // this.thmgr.Dispose(); // this.thmgr = null; // } // } // this.OnUnload(); //} //public virtual void OnUnload() //{ //} /// <summary> /// VIEW共通データを設定する /// </summary> /// <param name="cfg">VIEW共通データ</param> public void SetConfig(ViewsCommon cfg) { this.viewsCommData = cfg; if (this is UcLabelTwinTextBox || this is UcLabelComboBox) { this.thmgr = new ThreadManeger(cfg.DacConf); thmgr.OnReceived += new MessageReceiveHandler(OnReceived); } }