summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla35078.cs
blob: 054aca0f5eb0cfdb2605df675093824db037fc11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System.Threading.Tasks;
using Xamarin.Forms.CustomAttributes;

namespace Xamarin.Forms.Controls
{
	[Issue (IssueTracker.Bugzilla, 35078,
		"Checking IsInvokeRequired on WinRT when off the dispatcher thread causes a null reference exception",
		PlatformAffected.WinRT)]
	public class Bugzilla35078 : TestContentPage
	{
		protected override void Init ()
		{
			var button = new Button { Text = "Go" };

			var instructions = new Label {
				Text =
					"Click the 'Go' button. If the application crashes or a label with the text 'Sucess' does not appear, the test has failed."
			};

			var success = new Label ();

			button.Clicked += (sender, args) => {
				Task.Run (() => {
					bool invokeRequired = Device.IsInvokeRequired;
					if (invokeRequired) {
						Device.BeginInvokeOnMainThread (() => success.Text = "Success");
					}
				});
			};

			Content = new StackLayout { Children = { instructions, button, success } };
		}
	}
}