login about faq

When using asynchronous methods - you have created your own implementation of Task that cannot be awaited. While I looked at your example, it still is somewhat confusing to me. For example: what if I wanted to simply do

byte[] request = await clientSocket.ReadBytesAsync();
right now I am doing:
byte[] request = null;
await Task.Run(() =>
{
  request = clientSocket.ReadBytes();
}
which works fine, but is rather wasteful since you have the entire framework in there already. Can you please point me to the right docs?

asked Sep 02 at 09:23

chilkat's gravatar image

chilkat ♦♦
11.8k316358421


The reason Chilkat offers the Async alternatives for methods is to provide a consistent means for asynchronous functionality that is cross-platform and cross-language. Some environments may already provide async capability, and in that case you can freely choose one or the other. For example, using C# in VS2015 provides the the async/await C# language features. However, a programmer using VS2005 (.NET Framework 2.0) does not have async/await.

One difference is w/ the WinRT Chilkat API. In this case, the Chilkat methods are "awaitable" and there is no Chilkat.Task object. For example:

(awaitable) public IAsyncOperation<bool> GetFileAsync(string remoteFilePath, string localFilePath);

link

answered Sep 02 at 10:07

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

edited Sep 02 at 10:07

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×22
×9
×1

Asked: Sep 02 at 09:23

Seen: 177 times

Last updated: Sep 02 at 10:07

powered by OSQA