Programmers learn & share
0 votes
60 views

Problem :

I am facing following c# socket issue
the i/o operation has been aborted because of either a thread exit or an application request
by (6.9k points)   | 60 views

1 Answer

0 votes

Solution :

I had also encountered the same issue with RS232 communication. The reason behind this issue is your program executes faster than the slow serial communication.

The solution of the issue is as follows :

Stream s = this.GetStream();
IAsyncResult ar = s.BeginWrite(data, 0, data.Length, SendAsync, state);
if (!ar.IsCompleted)
    ar.AsyncWaitHandle.WaitOne();

Please Note: Most of the time ar.IsCompleted is true.

by (36.1k points)  
2,204 questions
2,604 answers
59 comments
241 users