void SaveFile() { Console.WriteLine("thread started"); byte[] bufer = new byte[1024]; int b = принятыйФайл.Read(bufer, 0, bufer.Length); while (b != 0) { localFile.Write(bufer, 0, b); b = принятыйФайл.Read(bufer, 0, bufer.Length); } Console.WriteLine("file saved"); localFile.Close(); string message = "file: " + filename; NewMessageEventArgs e = new NewMessageEventArgs(message); if (NewMessage != null) { NewMessage(this, e); Console.WriteLine("Event called"); } else { return; } }
public void NewMessageHandler(object sender, NewMessageEventArgs e) { MessageBox.Show("Event was called"); //textBox.Text += e.Message; if (e.Message.Contains("file: ")) { int a = e.Message.LastIndexOf("file: ") + 1; filename = e.Message.Remove(0, 6); принятыйФайл = obj.GetFile(filename); localFile = File.Create(filename); потокЗаписи.Start(); } else { RefreshMsgs(e.Message); } }
public void SendMessage(string msg) { Console.WriteLine(msg); NewMessageEventArgs e = new NewMessageEventArgs(msg); for (int i = 14; i > 0; i--) { messages[i] = messages[i - 1]; } messages[0] = msg; if (NewMessage != null) { NewMessage(this, e); Console.WriteLine("Event called"); } else { return; } }