-3

I have developed a GUI to capture packet via ethernet cable. For this purpose i have 3 separate functions I am running each function in separate thread.

1) public void Capture_Click(object sender, EventArgs e) //packet capturing

2) public static void PacketHandler(Packet packet) // storing received packets and showing in dataGrid

3) public void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e) // I have Kept a button on each row to get packet details in more detail.

Problem: When packets are coming that there is no problem but as soon as packet stop coming GUI freezes now I am not able to click Detail button in DataGrid.

suggest possible solution?

Peter
  • 27,590
  • 8
  • 64
  • 84
rkt_167
  • 7
  • 3
  • it's not obvious how you many these functions execute in separate threads. You did not supply enough code for the question to be clear. It is also far from clear how you appear to do UI operations in all three threads. – David Heffernan Jun 25 '14 at 06:13
  • @DavidHeffernan I am creating new thread for each of there function using, public Thread StartTheThread(object sender, EventArgs e) { var t = new Thread(() => Capture_Click(sender, e)); t.Start(); return t; } – rkt_167 Jun 25 '14 at 06:16
  • The doesn't look right, but there's little I can offer for limited excerpts written in comments – David Heffernan Jun 25 '14 at 06:21

1 Answers1

0

It seems you are receiving (psychic debugging) packages in your ui thread. A solution could be to do this in a background worker. This will allow your ui to update and receive/handle your incoming packages at the same time.

MSDN Backgroundworker

From MSDN: The BackgroundWorker class allows you to run an operation on a separate, dedicated thread. Time-consuming operations like downloads and database transactions can cause your user interface (UI) to seem as though it has stopped responding while they are running. When you want a responsive UI and you are faced with long delays associated with such operations, the BackgroundWorker class provides a convenient solution.

Peter
  • 27,590
  • 8
  • 64
  • 84