Advertisement
akass

nonlambda

May 16th, 2015
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. public class ThreadDemo : Activity
  2. {
  3.     TextView textview;
  4.  
  5.     protected override void OnCreate (Bundle bundle)
  6.     {
  7.         base.OnCreate (bundle);
  8.  
  9.         // Create a new TextView and set it as our view
  10.         textview = new TextView (this);
  11.         textview.Text = "Working..";
  12.  
  13.         SetContentView (textview);
  14.  
  15.         ThreadPool.QueueUserWorkItem (o => SlowMethod ());
  16.     }
  17.  
  18.     private void SlowMethod ()
  19.     {
  20.         Thread.Sleep (5000);
  21.         RunOnUiThread (() => textview.Text = "Method Complete");
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement