c# - Xamarin forms DisplayAlert not showing when called from a function called by a delegate -
when call greet inside size function displayalert displays alert expected when called delegate after event log output correct name (greet has been called) displayalert not show.
public class custompage : contentpage { ... protected override void onvalidsizeallocated(double width, double height) { ... greet("test"); app.fb.getname(); app.fb.namerecieved += (s,e) => { greet(e.name); }; } public void greet(string name) { utils.log("hey " + name); displayalert("hey " + name, "welcome", "ok"); } }
the code above outputs "hey test" , alert comes saying "hey test, welcome" ok button outputs "hey leo" (which correct because name facebook account) no alert shows.
is namereceived fired inside getname function?
maybe need put app.fb.getname() after "+={...};" block.
if namereceived correctly fired maybe greet not running on ui thread, try wrap display code in
device.begininvokeonmainthread (() => { displayalert("hey " + name, "welcome", "ok"); });
as described here
Comments
Post a Comment