c# - Can I declare a task without a Task block in Xamarin? -


So I found that annoyingly, with custom working methods, I always need to return a new task, such as below Foo0 (). But the interesting thing about zaminin is that if you enter an async keyword you can leave the new work block.

Foo0 and Foo1 are equivalent?

Is this a mess of implementation of Jämern, or does it work in VS 2012?

But Foo1 returns a compiler warning, and I just can not remove the async keyword, or it will stop compiling, even if the code body remains the same. (I've got an additional new work block in Foo0 redundant, this method should be clear from the announcement that I want to run a new job.)

  // is clear with a new return Working & lt; Int & gt; Foo0 () {Return Job.Run (() => {5 returns 5;}); } // gives the following warning: "There is a lack of waiting 'operator in the asynchronous block and in the synchronous manner" async task and lieutenant; Int & gt; Foo1 () {Return 5; } / * The following tasks & lt; Int & gt; Foo2 () {Return 5; } * /  

Is this a mess of Xamarin implementation, or does it Does VS work in 2012?

How does it work in async C # (both VS 2012 and XMarin)

It should be clear from the method declaration that I want to do a new job

Not a task at all is nothing more than "future"; It represents an asynchronous operation. A Possible The way to do this is working in the queue for the thread pool (like Task.Run ), but this is an rare approach Asynchronous World

Specifically, async does not work in the queue thread pool. This is not using Task. Run or anything like below. According to the compiler warning, this will run synchronous (on current thread) and then will already return the completed task. It is almost certainly not what you want, therefore warnings.

Then, Foo0 and Foo1 are completely different Foo0 queues work in the thread pool and the action Representing the task Foo1 works immediately and then returns the completed task in advance.

If you wait for async and .


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -