2
Answers

Interrupt a loop with toggle button

Kanthri

Kanthri

13y
2.5k
1
I have a tcpclient and tcpserver two different csharp programs. 

In tcpclient program I have created a toggle button. This toggle button when switched on creates a tcpclient and should continuously send data to the tcpserver. I have created  a for loop for sending data continuously. 

When toggle button is switched off data transfer should be stopped i.e. control should break out of for loop.

Can you please advise me about how can I make toggle button to initiate and interrupt the for loop?   
Answers (2)