I am implementing System.Web.UI.IPostBackEventHandler
on one of my classes and in the body of my implementation of void RaisePostBackEvent(string eventArgument)I am calling a method using the
async...await` syntax. E.g.
public void RaisePostBackEvent(string eventArgument)
{
if (eventArgument.Equals("deq1"))
{
Result result = await SaveDataAsync();
OnSaved();
}
}
However, it produces the error:
CS4033 - The 'await' operator can only be used within an async method
The question: Making interface implementations async describes an almost identical problem to mine, with the key difference being that the interface implemented by the OP was under his control, and the accepted answer was to change void DoSomething()
on the interface to Task DoSomething()
. However, I cannot change the IPostBackEventHandler
as it is part of the .NET Framework.
Any suggestions on how to solve this in a safe way?