コード例 #1
0
 public void myReadCallBack(IAsyncResult ar)
 {
     try
     {
         using (MemoryStream memStream = new MemoryStream(dataStream, 0, dataStream.Length, false))
         {
             var myNetworkStream = (NetworkStream)ar.AsyncState;
             var receivePacket2  = xs.Deserialize(memStream) as Packet;
             if (receivePacket2.IDTime != IDTimeOLD)
             {
                 receivePacket = receivePacket2;
                 if (computerInTaskHandler != null)
                 {
                     computerInTaskHandler.receivePacket = receivePacket;
                 }
                 HandleMessage(receivePacket);
                 if (receivePacket.dataIdentifier == DataIdentifier.SYN_FLAG || receivePacket.dataIdentifier == DataIdentifier.SYN_FLAG_WINPE)
                 {
                     Application.Current.Dispatcher.Invoke(() =>
                     {
                         listViewMachinesAndTasksHandler.Refresh();
                     });
                 }
             }
             IDTimeOLD = receivePacket.IDTime;
             myNetworkStream.BeginRead(dataStream, 0, dataStream.Length,
                                       new AsyncCallback(myReadCallBack),
                                       myNetworkStream);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
         clients.Remove(this);
         Application.Current.Dispatcher.Invoke(() =>
         {
             labelOnline.Content  = "Online: " + clients.Count;
             labelOffline.Content = "Offline: " + (clientsAll - clients.Count);
             listViewMachinesAndTasksHandler.Refresh();
         });
         offline = true;
         if (receivePacket != null)
         {
             receivePacket.dataIdentifier = DataIdentifier.Null;
         }
         if (computerInTaskHandler != null)
         {
             computerInTaskHandler.receivePacket = receivePacket;
         }
     }
 }
コード例 #2
0
        private void MenuItemTaskNew_Click(object sender, RoutedEventArgs e)
        {
            var taskOptionsDialog = new TaskOptions();

            taskOptionsDialog.path     = "";
            taskOptionsDialog.nodePath = treeViewMachinesAndTasksHandler.GetNodePath();
            taskOptionsDialog.clients  = listViewMachinesAndTasksHandler.clients;
            taskOptionsDialog.ExecutedTasksHandlers = ExecutedTasksHandlers;
            foreach (TaskData item in listViewTasks.Items)
            {
                taskOptionsDialog.Names.Add(item.Name);
            }
            taskOptionsDialog.ShowDialog();
            if (taskOptionsDialog.executed)
            {
                RunTask(taskOptionsDialog);
            }
            listViewMachinesAndTasksHandler.Refresh();
        }