public BeginRead ( byte buffer, int offset, int count, AsyncCallback callback, Object state ) : IAsyncResult | ||
buffer | byte | |
offset | int | |
count | int | |
callback | AsyncCallback | |
state | Object | |
리턴 | IAsyncResult |
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, Object state)
{
var result = new AsyncResult()
{
AsyncState = state,
CompletedSynchronously = true,
IsCompleted = true,
AsyncWaitHandle = new ManualResetEvent(true)
};
try
{
int bytesRead = this.Read(buffer, offset, count);
result.Return = bytesRead;
}
catch (Exception e)
{
result.Return = e;
}
if (callback != null)
callback(result);
return result;
}