-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
增加SubscribeOnMainThread避免订阅更新线程时出现问题
- Loading branch information
1 parent
b7f4adb
commit 07c3232
Showing
5 changed files
with
53 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Reactive.Linq; | ||
using System.Windows; | ||
using System.Windows.Threading; | ||
|
||
public static class ObservableExtensions | ||
{ | ||
public static IDisposable SubscribeOnMainThread<T>( | ||
this IObservable<T> source, | ||
Action<T> onNext) | ||
{ | ||
return source.Subscribe(item => | ||
{ | ||
Application.Current.Dispatcher.Invoke(() => | ||
{ | ||
onNext(item); | ||
}); | ||
}); | ||
} | ||
} |
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