Hi Guys,
I have a problem with a thread, it works, but when this discussion is in processing and the user click in menu bar of MasterDetailView and try open other Page this thread generate an Exception.
I try put a "Try Catch" for ignore the exception but don't work, the exception close the app.
The Exception occurs because the objects of Thread will become null.
Can anyone help me solve this? "The Thread":
new System.Threading.Thread (new System.Threading.ThreadStart (() => {
try {
Device.BeginInvokeOnMainThread (() => {
WaitState (true);
});
if (lQInfo.Count != 0) {
foreach (var item in lQInfo) {
var CustomPin = new TKCustomMapPin ();
CustomPin.ShowCallout = true;
CustomPin.DefaultPinColor = Color.Red;
CustomPin.Position = new Xamarin.Forms.Maps.Position (Convert.ToDouble (item.Y), Convert.ToDouble (item.X));
CustomPin.Title = item.Value.ToString ();
CustomPin.Subtitle = item.Endereco.TrimEnd () + "\r :" + item.IdPoint.ToString ();
Device.BeginInvokeOnMainThread (() => {
map.CustomPins.Add (CustomPin);
});
}
}
}
Device.BeginInvokeOnMainThread (() => {
WaitState (false);
});
} catch (Exception ex) {
}
})).Start ();