I am trying to activate my app from its own share contract (please - don't comment about whether or not this is okay to do from a Certification point of view... The app activation is done through a button on the share contract UI and will not happen unless the user proactively it. I am asking about the technical issue here, not about the user experience side of things - thanks!!)
The way I have it is set up is like this:
this.m_shareOperation.ReportStarted();
// ....
this.m_shareOperation.ReportCompleted();
await Launcher.LaunchUriAsync(new Uri("se-myapp:///something"));
Everything seems to work fine - the Activation event/override fires, the app actually activates and shows up, but then, AFTER my OnActivated code completes, the following error shows up:
The operation cannot be completed because the window is being closed. (Exception from HRESULT: 0x802A0201)
What can I do to make this work? Any idea?
The callstack where this appears is this (no user code, does not get handled by the UnhandledException event)...
mscorlib.dll!System.Threading.Tasks.AwaitTaskContinuation.ThrowAsyncIfNecessary.AnonymousMethod__1(object s) + 0x33 bytes mscorlib.dll!System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(object state) + 0x3e bytes mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0xa7 bytes mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0x16 bytes mscorlib.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() + 0x60 bytes mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() + 0x149 bytes mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() + 0x5 bytes [Native to Managed Transition]