Hi,
I'm using a BackgroundTask which is a Windows Runtime Component, and i figured out that i cannot wire up events.
My intent is, using a static class that has an event called OnCompleted to be subscribed outside the component. In this case, by a class that is inside in an UWP project.
Here's the code i implemented:
public static class Class1
{
public delegate EventHandler<BackgroundTaskProgressEventArgs> BackgroundTaskInProgress();
public delegate EventHandler<BackgroundTaskCompletedEventArgs> BackgroundTaskCompleted();
public static event BackgroundTaskInProgress InProgress;
public static event BackgroundTaskCompleted OnCompleted;
.....
private static void BackgroundTask_Progress(BackgroundTaskRegistration sender, BackgroundTaskProgressEventArgs args)
{
InProgress();
}
private static void BackgroundTask_Completed(BackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs args)
{
OnCompleted();
}
}
Meanwhile in UWP Project
....
Class1.InProgress += Class1_InProgress;
With this implementation, i get the following error: Nested Types cannot be exported to the Windows Runtime.
I took a look on this article, but i think i understood this could be done. Am i right?