Let's say I have a form with a piece of data that needs to be used in an await'ed method as such:
using (var riskForm = new RiskValidationForm(config))
{
if (riskForm.OpenDialog() == DialogResult.Cancel)
return;
await Task.Run(() => MyMethod(riskForm.GetRiskData());
}
Is this dangerous? I'm afraid that the form might dispose, getting rid of what RiskData() returns before the awaited method is started. Hence I'd be calling RiskData() on something that is already disposed of. Is this possible?
Function signature of MyMethod:
private void MyMethod(RiskLimitsConfigurationCollection riskLimits)