[Mono-bugs] [Bug 634711] New: Updating the UI from a thread not working

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Aug 26 07:34:29 EDT 2010



           Summary: Updating the UI from a thread not working
    Classification: Mono
           Product: MonoDroid
           Version: unspecified
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: Runtime
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: dan.ardelean at neologics.eu
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---

Description of Problem:
I've tried several ways of updating the UI from a thread but none of them work.

Steps to reproduce the problem:
1. I have a simple application with a textview as contentview and a menu item
When I press the menu I execute:
   (new System.Threading.Thread(tst.DoWork)).Start(); 
where tst is an object created inside OnCreate()

the tst object has an Android.OS.Handler member and a TextView initialized in
the constructor

2. Inside the DoWork method I have 
     handler.Post(new UpdateUI(tv, "Work started"));
            handler.Post(new UpdateUI(tv, "Work completed"));

 public class UpdateUI : Java.Lang.Thread
        TextView tv;
        string upd;
        public UpdateUI(TextView tv, string text)
            this.tv = tv;
            this.upd = text;
        public override void Run()
            tv.Text = tv.Text + "\r\n" + upd;


I've chosen Java.Lang.Thread because it's derived from IRunnable and there is
no Runnable class.

Maybe this is not the right way to update the UI but nothing that I've tried

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the mono-bugs mailing list