public void setTopRedditWallpaper_Button_Enabled(bool enabled)
 {
     if (InvokeRequired)
     {
         setTopRedditWallpaper_Button.BeginInvoke((System.Windows.Forms.MethodInvoker) delegate()
                                                  { this.setTopRedditWallpaper_Button.Enabled = enabled; });
         return;
     }
     setTopRedditWallpaper_Button.Enabled = enabled;
 }
Exemple #2
0
 private void RunReceiver()
 {
     //StopButton.BeginInvoke(new setButtonEnable(setButton), new object[] {StopButton, true });
     try {
         try {
             Socket = new System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Raw, System.Net.Sockets.ProtocolType.IP);
             try {
                 Socket.Bind(new System.Net.IPEndPoint(System.Net.IPAddress.Parse(selectip), 0));
                 Socket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.IP, System.Net.Sockets.SocketOptionName.HeaderIncluded, 1);
                 Socket.IOControl(unchecked ((int)0x98000001), new byte[4] {
                     1, 0, 0, 0
                 }, new byte[4]);
                 while (StopButton.Enabled)
                 {
                     System.IAsyncResult ar = Socket.BeginReceive(PacketBuffer, 0, PacketBufferSize, System.Net.Sockets.SocketFlags.None, new System.AsyncCallback(CallReceive), this);
                     while (Socket.Available == 0)
                     {
                         System.Threading.Thread.Sleep(1);
                         if (!StopButton.Enabled)
                         {
                             break;
                         }
                     }
                     if (!StopButton.Enabled)
                     {
                         break;
                     }
                     int Size = Socket.EndReceive(ar);
                     if (!LooseQueue.Checked)
                     {
                         ExtractBuffer();
                     }
                 }
             } finally {
                 if (Socket != null)
                 {
                     Socket.Shutdown(System.Net.Sockets.SocketShutdown.Both);
                     Socket.Close();
                 }
             }
         } finally {
             //StopButton.Enabled = false;
             //StartButton.Enabled = true;
             StartButton.BeginInvoke(new setButtonEnable(setButton), new object[] { StartButton, true });
             StopButton.BeginInvoke(new setButtonEnable(setButton), new object[] { StopButton, true });
         }
     } catch (System.Threading.ThreadAbortException) {
     } catch (System.Exception E) {
         System.Windows.Forms.MessageBox.Show(E.ToString());
     }
     //StartButton.BeginInvoke(new setButtonEnable(setButton), new object[] { StartButton, true });
     //StartButton.Enabled = true;
 }