020
This commit is contained in:
parent
016e83c8c8
commit
829ed1a8af
@ -6,5 +6,5 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace DTLib
|
||||
{
|
||||
public delegate Func<TEventArgs, Task> EventHandlerAsync<TEventArgs>(object sender, TEventArgs e);
|
||||
public delegate Task EventHandlerAsync<TEventArgs>(object sender, TEventArgs e);
|
||||
}
|
||||
|
||||
@ -8,6 +8,15 @@ namespace DTLib.Reactive
|
||||
{
|
||||
public class ReactiveListener<T> : ReactiveWorker<T>
|
||||
{
|
||||
|
||||
public ReactiveListener()
|
||||
{
|
||||
StreamCollectionAccess.Execute(() =>
|
||||
{
|
||||
foreach(var stream in Streams)
|
||||
{
|
||||
stream.ElementAdded += async (sender, value) => { await Task.Run(() =>{ }); };
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,9 +8,9 @@ namespace DTLib.Reactive
|
||||
{
|
||||
public abstract class ReactiveWorker<T>
|
||||
{
|
||||
List<ReactiveStream<T>> Streams = new();
|
||||
protected List<ReactiveStream<T>> Streams = new();
|
||||
|
||||
SafeMutex StreamCollectionAccess = new();
|
||||
protected SafeMutex StreamCollectionAccess = new();
|
||||
|
||||
public void Join(ReactiveStream<T> stream) => StreamCollectionAccess.Execute(()=>Streams.Add(stream));
|
||||
public void Leave(ReactiveStream<T> stream) => StreamCollectionAccess.Execute(() => Streams.Remove(stream));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user