protected override void WndProc(ref Message m) { if (m.Msg == WindowsAPI.WM_COPYDATA) { byte[] b = new Byte[Marshal.ReadInt32(m.LParam, IntPtr.Size)]; IntPtr dataPtr = Marshal.ReadIntPtr(m.LParam, IntPtr.Size * 2); Marshal.Copy(dataPtr, b, 0, b.Length); string newMessage = System.Text.Encoding.Unicode.GetString(b); if (newMessage.StartsWith("END FO INIT|COPY")) { this.OPType = OperationType.Copy; } if (newMessage.StartsWith("END FO INIT|MOVE")) { this.OPType = OperationType.Move; } if (newMessage.StartsWith("END FO INIT|DELETE")) { this.OPType = OperationType.Delete; } if (newMessage.Contains("DeleteTORB")) { this.DeleteToRB = true; } if (newMessage.StartsWith("INPUT|")) { var parts = newMessage.Replace("INPUT|", "").Split(Char.Parse("|")); SourceItemsCollection.Add(new Tuple <string, string, int>(parts[0].Trim(), parts[1].Trim(), Convert.ToInt32(parts[2].Trim()))); } if (newMessage.StartsWith("END FO INIT")) { _block.Set(); CopyThread = new Thread(new ThreadStart(CopyFiles)); CopyThread.IsBackground = false; CopyThread.Start(); CopyThread.Join(1); } if (newMessage.StartsWith("COMMAND|")) { var realMessage = newMessage.Replace("COMMAND|", String.Empty); switch (realMessage) { case "STOP": this.Cancel = true; _block.Set(); _block2.Set(); break; case "PAUSE": _block.Reset(); break; case "CONTINUE": _block.Set(); break; case "CLOSE": Close(); break; default: break; } } } base.WndProc(ref m); }