I appreciate GetAsync is, well, asynchronous however I can't find any documentation as to how to use it. At this stage all I want is to get my name and assign that to a text block. Of course if I do this within the _fbClient.GetCompleted += / _fbClient.GetAsync("/me") block, it get the invalid cross thread access exception error.
In the code below the NameTextBlock control is of course set to "[EMPTY]" and some time later the line marked =======> is executed which results in the error.
The few examples I've seen use what appears to be a synchronous Get method but that seems to have gone (and I wouldn't want to use it anyway).
string name = "EMPTY";
try
{
_fbClient.GetCompleted +=
(o, e) =>
{
if (e.Error == null)
{
var result = (IDictionary<string, object>)e.GetResultData();
//Dispatcher.BeginInvoke(() => MyData.ItemsSource = result);
var tempname = (string)result["name"];
name = (string)result["name"];
NameTextBlock.Text = "[" + name + "]";
}
else
{
MessageBox.Show(e.Error.Message);
}
};
_fbClient.GetAsync("/me");
//======> NameTextBlock.Text = "[" + name + "]";
}
catch
{
MessageBox.Show("Failed.. deal with issues.");
}
finally
{
NameTextBlock.Text = "[" + name + "]";
}