c# - Xamarin Forms UI Thread not working -
i trying create countdown timer inside thread updated in ui of application. have problem using reference `system.threading.thread.
using system.globalization; using system.threading; new system.threading.thread(new system.threading.threadstart(() => { invokeonmainthread(() => { this.timer1 = this.timer1.adddays(16); this.timer1 = this.timer1.addmonths(10); this.timer1 = this.timer1.addyears(2015); this.timer2 = datetime.now; this.result = this.timer1.subtract(this.timer2); nbjour = this.result.days.tostring(); nbheure = this.result.hours.tostring(); nbmin = this.result.minutes.tostring(); }); })).start();
thread
, threadstart()
underlined red, no error message.
use device.begininvokeonmainthread
instead of invokeonmainthread
or use task
.
device.begininvokeonmainthread( () => { ... } );
Comments
Post a Comment