Hi,
I was trying to follow the documentation. Integration Page page suggests to put the following snippet into the Main function:
using (var mgr = new UpdateManager("C:\\Projects\\MyApp\\Releases"))
{
await mgr.UpdateApp();
}
But, for this the Main function needs to be async and which is not being allowed by compiler. So, am I missing something here or is there a different way to achieve it?
Best Regards,
Santosh
you can call an async function from your main function ;)
so just create a
async static void update()
{
using (var mgr = new UpdateManager("C:\\Projects\\MyApp\\Releases"))
{
await mgr.UpdateApp();
}
}
Thanks @d0narnbl1tz . It helps. Do we need the document to say so. Because I think many people may be naive just like me.
Did you miss making the update a static method? Note static keyword
below.
async static void update()
{
using (var mgr = new UpdateManager("C:\\Projects\\MyApp\\Releases"))
{
await mgr.UpdateApp();
}
}
yup that was it - thanks!
So I'm gathering that the recommended practice is to have an async void update method that you call from Main(). That way the update will happen in the background while your app runs. This wasn't at all clear to me from the documentation though, it would really help to have this more spelled out.
But, for this the Main function needs to be async and which is not being allowed by compiler.
This is now allowed as part of C# 7.2 and I've opened #1475 to close this out...
Most helpful comment
Thanks @d0narnbl1tz . It helps. Do we need the document to say so. Because I think many people may be naive just like me.