I am trying to understand how to update a UI from an event while using async/await pattern. Below is the test code I am using on a WinForm app. I am not even sure this is th
Here is another example
async void DoExport()
{
var rMsg = "";
var t = await Task.Factory.StartNew(() => ExportAsMonthReport(LastMonth.Name, LastYear.Name, out rMsg));
if (t)
{
BeginInvoke((Action)(() =>
{
spinnerMain.Visible = false;
menuItemMonth.Enabled = true;
MetroMessageBox.Show(this, rMsg, "Export", MessageBoxButtons.OK, MessageBoxIcon.Information, 200);
}));
}
else
{
BeginInvoke((Action)(() =>
{
spinnerMain.Visible = false;
menuItemMonth.Enabled = true;
MetroMessageBox.Show(this, rMsg, "Export", MessageBoxButtons.OK, MessageBoxIcon.Error, 200);
}));
}
}