• 1000 значения, необходимые в его собственном классе для доступа извне.
Однако, когда я добираюсь до сохранения данных в текстовых полях, я получаю это сообщение об ошибке.
System.Exception
HResult=0x8001010E
Message=The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))
Source=Windows
StackTrace:
at Windows.UI.Xaml.Controls.TextBlock.put_Text(String value)
at Xamarin.Forms.Platform.UWP.LabelRenderer.UpdateTextPlainText(TextBlock textBlock)
at Xamarin.Forms.Platform.UWP.LabelRenderer.UpdateText(TextBlock textBlock)
at Xamarin.Forms.Platform.UWP.LabelRenderer.OnElementPropertyChanged(Object sender, PropertyChangedEventArgs e)
at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
at Xamarin.Forms.BindableObject.OnPropertyChanged(String propertyName)
at Xamarin.Forms.Element.OnPropertyChanged(String propertyName)
at Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent)
at Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes)
at Xamarin.Forms.BindableObject.SetValue(BindableProperty property, Object value, Boolean fromStyle, Boolean checkAccess)
at Xamarin.Forms.Label.set_Text(String value)
at MajorProjectTvApplication.SearchView.<searchShow>d__15.MoveNext() in D:\Tafe Work\Mobile Apps\wk12\MajorProjectTvApplication\MajorProjectTvApplication\MajorProjectTvApplication\SearchView.xaml.cs:line 70
Из-за этого Я совершенно не уверен, как это обойти, поэтому любые мысли и идеи могут мне помочь.
Класс LoadTvShows предоставляется на случай:
public class LoadTVShows
{
public string name;
public string summary;
public string time;
public string country;
public async Task<bool> GetAPI(string searchString)
{
string search = searchString;
try
{
using (var client = new HttpClient())
{
var response = await client.GetAsync("http://api.tvmaze.com/singlesearch/shows?q=" + search + "");
var responseString = await response.Content.ReadAsStringAsync();
var rawTvListings = JsonConvert.DeserializeObject<OpenTVGuideResponse>(responseString);
name = rawTvListings.Name;
time = rawTvListings.Schedule.Time;
summary = rawTvListings.Summary;
country = rawTvListings.Network.Country.Code;
return true;
}
}
catch (HttpRequestException httpRequestError)
{
return false;
}
}
}
public class OpenTVGuideResponse
{
public string Name { get; set; }
public GetTime Schedule { get; set; }
public string Summary { get; set; }
public GetNetwork Network { get; set; }
}
public class GetTime
{
public string Time { get; set; }
}
public class GetNetwork
{
public GetCountry Country { get; set; }
}
public class GetCountry
{
public string Code { get; set; }
}