-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Context Delegate Subscribe failed when running from thread pool thread. Created a static exec method that returns the current TaskScheuler becuase the SynchronizationContext was null 2. RegisterService TFrom, TTO caused a bug in the init routine, it caused the service to be created twice.
- Loading branch information
Showing
23 changed files
with
190 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using MvvmKit; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Unity; | ||
|
||
namespace MvvmKitAppSample.Services | ||
{ | ||
public class BgService1 : BackgroundServiceBase, IBgService1 | ||
{ | ||
private IBgService2 _svc; | ||
|
||
protected override async Task OnInit() | ||
{ | ||
await base.OnInit(); | ||
|
||
// init logic here | ||
await _svc.OnString.Subscribe(this, OnString); | ||
} | ||
|
||
private async Task OnString(string arg) | ||
{ | ||
await Task.Delay(1000); | ||
Debug.WriteLine("Hey Baby! " + arg); | ||
} | ||
|
||
[InjectionMethod] | ||
public void Inject(IBgService2 svc) | ||
{ | ||
// store dependencies here | ||
_svc = svc; | ||
} | ||
|
||
public Task Method() | ||
{ | ||
return Run(() => | ||
{ | ||
// your logic here | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using MvvmKit; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Unity; | ||
|
||
namespace MvvmKitAppSample.Services | ||
{ | ||
public class BgService2 : BackgroundServiceBase, IBgService2 | ||
{ | ||
public AsyncEvent<string> OnString { get; } = new AsyncEvent<string>("First Value"); | ||
|
||
protected override async Task OnInit() | ||
{ | ||
await base.OnInit(); | ||
|
||
// init logic here | ||
} | ||
|
||
public static int counter = 0; | ||
public int id; | ||
|
||
public BgService2() | ||
{ | ||
id = ++counter; | ||
} | ||
|
||
[InjectionMethod] | ||
public void Inject() | ||
{ | ||
// store dependencies here | ||
} | ||
|
||
public Task Method() | ||
{ | ||
return Run(() => | ||
{ | ||
// your logic here | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace MvvmKitAppSample.Services | ||
{ | ||
public interface IBgService1 | ||
{ | ||
Task Method(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Threading.Tasks; | ||
using MvvmKit; | ||
|
||
namespace MvvmKitAppSample.Services | ||
{ | ||
public interface IBgService2 | ||
{ | ||
AsyncEvent<string> OnString { get; } | ||
|
||
Task Method(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+0 Bytes
(100%)
Extensions/MvvmKitExtension/ProjectTemplates/Mvvm/An MvvmKit Application.zip
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.