title: Why exception System.Threading.Tasks.TaskCanceledException?
body: <p>I am building a xamarin android application but cant use async await.</p>
  
  <p>The execution gets stuck for very long time and then finally throws exception with message: <strong>System.Threading.Tasks.TaskCanceledException: A task was canceled</strong></p>
  
  <p>First I thought it's getting stuck because I din't use ConfigureAwait(false), but using it din't solve anything.</p>
  
  <p>code: </p>
  
  <pre><code>protected override async void OnCreate(Bundle bundle)
  {
      base.OnCreate(bundle);
      await ProcessData().ConfigureAwait(false); 
  }
  
  private async Task ProcessData()
  {
      await Task.Delay(new TimeSpan(0, 0, 2)).ConfigureAwait(false); // 2 seconds
  }
  </code></pre>
  
  <p>stack trace:</p>
  
  <pre><code>Thread started: &lt;Thread Pool&gt; #6
  11-11 15:11:06.144 W/        (19542): _wapi_connect: error looking up socket handle 0x26
  11-11 15:11:06.177 D/Mono    (19542): DllImport attempting to load: '/system/lib/liblog.so'.
  11-11 15:11:06.177 D/Mono    (19542): DllImport loaded library '/system/lib/liblog.so'.
  11-11 15:11:06.177 D/Mono    (19542): DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so').
  11-11 15:11:06.177 D/Mono    (19542): Searching for '__android_log_print'.
  11-11 15:11:06.177 D/Mono    (19542): Probing '__android_log_print'.
  11-11 15:11:06.177 D/Mono    (19542): Found as '__android_log_print'.
  11-11 15:11:06.178 I/MonoDroid(19542): UNHANDLED EXCEPTION:
  11-11 15:11:06.179 I/MonoDroid(19542): System.Threading.Tasks.TaskCanceledException: A task was canceled.
  11-11 15:11:06.179 I/MonoDroid(19542): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () &lt;IL 0x00011, 0x0004b&gt;
  11-11 15:11:06.179 I/MonoDroid(19542): at System.Runtime.CompilerServices.AsyncMethodBuilderCore.&lt;ThrowAsync&gt;m__0 (object) &lt;IL 0x00006, 0x0003b&gt;
  11-11 15:11:06.179 I/MonoDroid(19542): at Android.App.SyncContext/&lt;Post&gt;c__AnonStorey0.&lt;&gt;m__0 () &lt;IL 0x0000c, 0x00032&gt;
  11-11 15:11:06.179 I/MonoDroid(19542): at Java.Lang.Thread/RunnableImplementor.Run () &lt;IL 0x00011, 0x0004c&gt;
  11-11 15:11:06.179 I/MonoDroid(19542): at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) &lt;IL 0x0000a, 0x0005e&gt;
  11-11 15:11:06.179 I/MonoDroid(19542): at (wrapper dynamic-method) object.b257f262-40d0-43f7-b8b4-43d0ec65bc72 (intptr,intptr) &lt;IL 0x00011, 0x0001f&gt;
  11-11 15:11:06.186 W/art     (19542): JNI RegisterNativeMethods: attempt to register 0 native methods for md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable
  11-11 15:11:06.188 D/AndroidRuntime(19542): Shutting down VM
  An unhandled exception occured.
  
  11-11 15:12:58.748 E/AndroidRuntime(19542): FATAL EXCEPTION: main
  11-11 15:12:58.748 E/AndroidRuntime(19542): Process: AndroidConsumer.AndroidConsumer, PID: 19542
  11-11 15:12:58.748 E/AndroidRuntime(19542): java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
  11-11 15:12:58.748 E/AndroidRuntime(19542):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
  11-11 15:12:58.748 E/AndroidRuntime(19542): Caused by: java.lang.reflect.InvocationTargetException
  11-11 15:12:58.748 E/AndroidRuntime(19542):     at java.lang.reflect.Method.invoke(Native Method)
  11-11 15:12:58.748 E/AndroidRuntime(19542):     at java.lang.reflect.Method.invoke(Method.java:372)
  11-11 15:12:58.748 E/AndroidRuntime(19542):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
  11-11 15:12:58.748 E/AndroidRuntime(19542):     ... 1 more
  11-11 15:12:58.748 E/AndroidRuntime(19542): Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.Threading.Tasks.TaskCanceledException: A task was canceled.
  11-11 15:12:58.748 E/AndroidRuntime(19542): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () &lt;IL 0x00011, 0x0004b&gt;
  11-11 15:12:58.748 E/AndroidRuntime(19542): at System.Runtime.CompilerServices.AsyncMethodBuilderCore.&lt;ThrowAsync&gt;m__0 (object) &lt;IL 0x00006, 0x0003b&gt;
  11-11 15:12:58.748 E/AndroidRuntime(19542): at Android.App.SyncContext/&lt;Post&gt;c__AnonStorey0.&lt;&gt;m__0 () &lt;IL 0x0000c, 0x00032&gt;
  11-11 15:12:58.748 E/AndroidRuntime(19542): at Java.Lang.Thread/RunnableImplementor.Run () &lt;IL 0x00011, 0x0004c&gt;
  11-11 15:12:58.748 E/AndroidRuntime(19542): at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) &lt;IL 0x0000a, 0x0005e&gt;
  11-11 15:12:58.748 E/AndroidRuntime(19542): at (wrapper dynamic-method) object.b257f262-40d0-43f7-b8b4-43d0ec65bc72 (intptr,intptr) &lt;IL 0x00011, 0x0001f&gt;
  11-11 15:12:58.748 E/AndroidRuntime(19542): 
  11-11 15:12:58.748 E/AndroidRuntime(19542):     at mono.java.lang.RunnableImplementor.n_run(Native Method)
  11-11 15:12:58.748 E/AndroidRuntime(19542):     at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:29)
  11-11 15:12:58.748 E/AndroidRuntime(19542):     at android.os.Handler.handleCallback(Handler.java:739)
  11-11 15:12:58.748 E/AndroidRuntime(19542):     at android.os.Handler.dispatchMessage(Handler.java:95)
  11-11 15:12:58.748 E/AndroidRuntime(19542):     at android.os.Looper.loop(Looper.java:135)
  11-11 15:12:58.748 E/AndroidRuntime(19542):     at android.app.ActivityThread.main(ActivityThread.java:5253)
  11-11 15:12:58.748 E/AndroidRuntime(19542):     ... 4 more
  11-11 15:12:58.877 I/Process (19542): Sending signal. PID: 19542 SIG: 9
  </code></pre>