private void PackageData(object obj) { WeaveNetWorkItems netc = obj as WeaveNetWorkItems; List <byte[]> ListData = netc.DataList; try { int i = 0; int count = ListData.Count; if (count > 0) { int bytesRead = ListData[i] != null ? ListData[i].Length : 0; if (bytesRead == 0) { if (ListData.Count > 0) { ListData.RemoveAt(0); } netc.IsPage = false; return; } ; byte[] tempbtye = new byte[bytesRead]; Array.Copy(ListData[i], tempbtye, tempbtye.Length); try { DtuModel dd = new DtuModel(); dd.Data = tempbtye; dd.Soc = netc.SocketSession; if (weaveReceiveDtuEvent != null) { ThreadPool.QueueUserWorkItem(new WaitCallback(DtuReceiveEventCallBack), dd); } // receiveeventDtu.BeginInvoke(tempbtye, netc.Soc, null, null); if (ListData.Count > 0) { ListData.RemoveAt(i); } netc.IsPage = false; return; } catch { netc.IsPage = false; return; } } } catch { if (netc.DataList.Count > 0) { netc.DataList.RemoveAt(0); } netc.IsPage = false; return; } finally { netc.IsPage = false; } }
private void DtuReceiveEventCallBack(object state) { DtuModel dd = state as DtuModel; weaveReceiveDtuEvent(dd.Data, dd.Soc); }