title: How to create a Task/TPL based work queue/event loop?
body: <p>I have a system where all database operations (SQLite) must be run through the use of a work processor so i can schedule them however i like.</p>
  
  <p>Right now the processor has a <code>Task&lt;TResult&gt; PostAsync&lt;TResult&gt;(Func&lt;SQLiteConnection, TResult&gt; dbFunc)</code> but the only sane implementation i've been able to come up with is a stack-based UI-thread worker loop that leverages <code>Task</code> to be able to defer the result up to the moment the actual action is processed.</p>
  
  <p>It works fine but it is clogging up the UI thread with the SQLite calls. I'd rather have that not happen but the only idea i have been able to come up with is to spawn a worker thread to flush the queue or to give each action it's own worker thread. I don't think either one of these is the most sane approach as they'd end up creating threads everytime DB access is needed.</p>
  
  <p>How can i achieve an implementation where the <code>dbFunc</code> arguments in the stack are executed in a background thread but said thread is only created once or is as lightweight as possible?</p>
  
  <p>This has to work in a Xamarin environment. Either in PCL or Android+iOS implementations.</p>