getting right to it here is a few lines from the code I have in my code behind:
private static Factual factual = new Factual(FACTUAL_KEY, FACTUAL_SECRET);
private void OnStartQueries_Click(object sender, RoutedEventArgs e)
{
RunAsyncQuery(43.0120, -81.2003, 3000, 25).ContinueWith(task => rtbJsonData.AppendText(task.Result));
}
private static async Task<string> RunAsyncQuery(double lat, double lng, int radius, int limit)
{
return await Task.Run(() => factual.Fetch("places", new Query().WithIn(new Circle(lat, lng, radius)).Limit(limit)));
}
So as you can see when I click the Start Queries button I want to run a method asynchronously. When it returns with the result from that query, I want to set the text of the RichTextBox "rtbJsonData" to the result. However, currently when I run it I get the exception:
"The calling thread cannot access this object because a different thread owns it."
How can I do this?