EventEmitter/EventEmitter.cs
/// <summary>
/// Emits the event and runs all associated methods asynchronously
/// </summary>
/// <param name="eventName">The event name to call methods for</param>
/// <param name="data">The data to call all the methods with</param>
Emits the event and runs all associated methods asynchronously
Emits the event and runs all associated methods asynchronously
public void Emit(string eventName, object? data = null)
        {
            _rwl.EnterReadLock();
            if (!_events.TryGetValue(eventName, out var subscribedMethods))
            {
            }
            else
            {
                foreach (var f in subscribedMethods)
                {
                    f(eventName, data).ContinueWith(val =>
                    {
                        val.Exception!.Handle(ex =>
                        {
                            Debug.WriteLine("Emit fail:{0}", ex);
                            return true;
                        });
                    }, TaskContinuationOptions.OnlyOnFaulted);
                }
            }
            _rwl.ExitReadLock();
        }
public void Emit ( string eventName , object ? data = null ) { _rwl . EnterReadLock ( ) ; if ( ! _events . TryGetValue ( eventName , out var subscribedMethods ) ) { } else { foreach ( var f in subscribedMethods ) { f ( eventName , data ) . ContinueWith ( val => { val . Exception ! . Handle ( ex => { Debug . WriteLine ( " " , ex ) ; return true ; } ) ; } , TaskContinuationOptions . OnlyOnFaulted ) ; } } _rwl . ExitReadLock ( ) ; }
Emits the event and runs all associated methods asynchronously
Emits the event and runs all associated methods asynchronously
//throw new DoesNotExistException(string.Format("Event [{0}] does not exist in the emitter. Consider calling EventEmitter.On", eventName));
eventName
string
The event name to call methods for
The event name to call methods for
data
object?
The data to call all the methods with
The data to call all the methods with