/// <summary> /// Creates a new Lavalink service with specified configuration options. /// </summary> /// <param name="cfg">Lavalink configuration.</param> /// <param name="client">Discord client to which the Lavalink will be attached.</param> public LavalinkService(CompanionCubeConfigLavalink cfg, DiscordClient client) { this.Configuration = cfg; this.Discord = client; this.Discord.Ready += this.Client_Ready; this._trackException = new AsyncEvent <LavalinkGuildConnection, TrackExceptionEventArgs>("CCUBE_LAVALINK_TRACK_EXCEPTION", TimeSpan.Zero, this.EventExceptionHandler); }
private YearsGrid(DateTime start) { Columns = YearColumns; YearTapped = new AsyncEvent <DateTime>(); YearButtons = new List <ItemButton>(); ChangeDate(start); }
protected void Raise(Delegate eventMethod, params object[] eventParameters) { if (eventMethod == null) { return; } var asyncEvent = new AsyncEvent() { Sender = this, EventMethod = eventMethod, Parameters = eventParameters }; if (_eventThread == null) { if (ThreadPool.QueueUserWorkItem(new WaitCallback(ExecuteAsyncEvent), asyncEvent) == false) { this.Error("Asynchronous execution of event method '{0}' failed!", eventMethod.Method.Name); } return; } lock (_eventQueue) { _eventQueue.Enqueue(asyncEvent); } _newEvent.Set(); }
private void RunAsyncEventProvider() { var waitHandles = new WaitHandle[] { _newEvent, _shutdown }; while (waitHandles[WaitHandle.WaitAny(waitHandles)] != _shutdown) { AsyncEvent asyncEvent = null; do { lock (_eventQueue) { asyncEvent = _eventQueue.Count > 0 ? _eventQueue.Dequeue() : null; } if (asyncEvent != null) { try { asyncEvent.EventMethod.DynamicInvoke(asyncEvent.Parameters); } catch (Exception ex) { this.Error("Raising event '{0}' failed!", ex, asyncEvent.EventMethod.GetType().Name); } } }while (asyncEvent != null); } }
/// <summary> /// Initialize the instance. /// </summary> /// <param name="owner">The object that "owns" this operation (or <c>null</c>).</param> /// <param name="callback">The delegate to call when the operation completes.</param> /// <param name="state">The application defined state.</param> /// <remarks> /// The owner parameter is optionally used to identify the object that "owns" /// this operation. This parameter may be null or any object type. Additional /// information will be tracked by <see cref="AsyncTracker" /> if the object implements the /// <see cref="IAsyncResultOwner" /> interface. /// </remarks> public AsyncResult(object owner, AsyncCallback callback, object state) { this.owner = owner; this.callback = callback; this.asyncState = state; this.internalState = default(TInternalState); this.ttd = DateTime.MaxValue; this.result = default(TResult); this.wait = null; this.isCompleted = false; this.syncCompletion = false; this.exception = null; this.notifyQueued = false; #if DEBUG && !MOBILE_DEVICE this.isWaiting = false; this.isReleased = false; this.traceID = -1; this.traceName = null; this.inCallback = false; this.disposed = false; this.createStack = CallStack.AsyncTrace(1, true); this.startStack = null; this.notifyStack = null; this.completeStack = null; this.waitStack = null; #endif }
public void TestEvent() { for (int i = 0; i < 5; i++) { AsyncEvent.ExternalEvent("111", "2222", "3333"); } }
/// <summary> /// Creates the asynchronous event operation. /// </summary> /// <param name="asyncEvent">The asynchronous event.</param> /// <param name="poolHandler">The pool handler.</param> /// <returns></returns> public IThreadPoolOperation CreateAsyncEventOperation(AsyncEvent asyncEvent, IAsyncEventExecutionEngine poolHandler) { var asyncEventOperation = new AsyncEventOperation(asyncEvent, poolHandler, this.EventLog); this.ApplyBehaviors(asyncEventOperation); return asyncEventOperation; }
public LavalinkService(BotConfigService cfg, DiscordShardedClient client) { this.cfg = cfg.CurrentConfiguration.LavalinkConfig; this.client = client; this.client.Ready += this.InitializeLavalinkAsync; this.trackError = new AsyncEvent <LavalinkGuildConnection, TrackExceptionEventArgs>("LAVALINK_ERROR", TimeSpan.Zero, this.LavalinkErrorHandler); }
public ChatWindowViewModel(ChatWindowViewModelSettings settings, List <TranslationEngine> translationEngines, List <ChatMsgType> allChatCodes, HotKeyManager hotKeyManager) { this._AsyncPropertyChanged = new AsyncEvent <AsyncPropertyChangedEventArgs>(this.EventErrorHandler, "ChatWindowViewModel \n AsyncPropertyChanged"); this._RequestChatClear = new AsyncEvent <TatruEventArgs>(this.EventErrorHandler, "ChatWindowViewModel \n RequsetChatClear"); ShowChatWindowCommand = new TataruUICommand(ShowChatWindow); RestChatWindowPositionCommand = new TataruUICommand(ResetChatWindowPosition); _IsWindowVisible = true; Name = settings.Name; _WinId = settings.WinId; ChatFontSize = settings.ChatFontSize; LineBreakHeight = settings.LineBreakHeight; SpacingCount = settings.SpacingCount; IsAlwaysOnTop = settings.IsAlwaysOnTop; IsClickThrough = settings.IsClickThrough; IsAutoHide = settings.IsAutoHide; AutoHideTimeout = settings.AutoHideTimeout; IsHiddenByUser = false; BackGroundColor = settings.BackGroundColor; TranslationEngines = new CollectionView(translationEngines); var tmpEngine = translationEngines.FirstOrDefault(x => x.EngineName == settings.TranslationEngineName); TranslationEngines.MoveCurrentToFirst(); if (tmpEngine != null) { if (TranslationEngines.Contains(tmpEngine)) { TranslationEngines.MoveCurrentTo(tmpEngine); } else { TranslationEngines.MoveCurrentToFirst(); } } OnTranslationEngineChange(this, null); TrySetLangugue(_TranslateFromLanguagues, settings.FromLanguague); TrySetLangugue(_TranslateToLanguagues, settings.ToLanguague); ChatWindowRectangle = settings.ChatWindowRectangle; ChatCodes = LoadChatCodes(settings.ChatCodes, allChatCodes); _HotKeyManager = hotKeyManager; ShowHideChatKeys = new HotKeyCombination(settings.ShowHideChatKeys); ClickThoughtChatKeys = new HotKeyCombination(settings.ClickThoughtChatKeys); ClearChatKeys = new HotKeyCombination(settings.ClearChatKeys); _HotKeyManager.GlobalHotKeyPressed += OnGlobalHotKeyPressed; }
internal LavalinkNodeConnection(DiscordClient client, LavalinkExtension extension, LavalinkConfiguration config) { this.Discord = client; this.Parent = extension; this.Configuration = new LavalinkConfiguration(config); if (config.Region != null && this.Discord.VoiceRegions.Values.Contains(config.Region)) { this.Region = config.Region; } this.ConnectedGuilds = new ReadOnlyConcurrentDictionary <ulong, LavalinkGuildConnection>(this._connectedGuilds); this.Statistics = new LavalinkStatistics(); this._lavalinkSocketError = new AsyncEvent <LavalinkNodeConnection, SocketErrorEventArgs>("LAVALINK_SOCKET_ERROR", TimeSpan.Zero, this.Discord.EventErrorHandler); this._disconnected = new AsyncEvent <LavalinkNodeConnection, NodeDisconnectedEventArgs>("LAVALINK_NODE_DISCONNECTED", TimeSpan.Zero, this.Discord.EventErrorHandler); this._statsReceived = new AsyncEvent <LavalinkNodeConnection, StatisticsReceivedEventArgs>("LAVALINK_STATS_RECEIVED", TimeSpan.Zero, this.Discord.EventErrorHandler); this._playerUpdated = new AsyncEvent <LavalinkGuildConnection, PlayerUpdateEventArgs>("LAVALINK_PLAYER_UPDATED", TimeSpan.Zero, this.Discord.EventErrorHandler); this._playbackStarted = new AsyncEvent <LavalinkGuildConnection, TrackStartEventArgs>("LAVALINK_PLAYBACK_STARTED", TimeSpan.Zero, this.Discord.EventErrorHandler); this._playbackFinished = new AsyncEvent <LavalinkGuildConnection, TrackFinishEventArgs>("LAVALINK_PLAYBACK_FINISHED", TimeSpan.Zero, this.Discord.EventErrorHandler); this._trackStuck = new AsyncEvent <LavalinkGuildConnection, TrackStuckEventArgs>("LAVALINK_TRACK_STUCK", TimeSpan.Zero, this.Discord.EventErrorHandler); this._trackException = new AsyncEvent <LavalinkGuildConnection, TrackExceptionEventArgs>("LAVALINK_TRACK_EXCEPTION", TimeSpan.Zero, this.Discord.EventErrorHandler); this.VoiceServerUpdates = new ConcurrentDictionary <ulong, TaskCompletionSource <VoiceServerUpdateEventArgs> >(); this.VoiceStateUpdates = new ConcurrentDictionary <ulong, TaskCompletionSource <VoiceStateUpdateEventArgs> >(); this.Discord.VoiceStateUpdated += this.Discord_VoiceStateUpdated; this.Discord.VoiceServerUpdated += this.Discord_VoiceServerUpdated; this.Rest = new LavalinkRestClient(this.Configuration, this.Discord); Volatile.Write(ref this._isDisposed, false); }
private WebSocketClient(IWebSocketOptions options) { _connected = new AsyncEvent(EventErrorHandler, "WS_CONNECT"); _disconnected = new AsyncEvent <WebSocketCloseEventArgs>(EventErrorHandler, "WS_DISCONNECT"); _messageReceived = new AsyncEvent <WebSocketMessageEventArgs>(EventErrorHandler, "WS_MESSAGE"); _errored = new AsyncEvent <WebSocketErrorEventArgs>(EventErrorHandler, "WS_ERROR"); Options = options; ClientWebSocket = new ClientWebSocket { Options = { KeepAliveInterval = TimeSpan.Zero } }; if (options.WebProxy != null) { ClientWebSocket.Options.Proxy = options.WebProxy; } if (options.Headers.Any()) { foreach (var(k, v) in options.Headers) { ClientWebSocket.Options.SetRequestHeader(k, v); } } SocketTokenSource = null; SocketToken = CancellationToken.None; ReceiverTokenSource = null; ReceiverToken = CancellationToken.None; Locker = new SemaphoreSlim(1); }
protected AsyncReply(ResponseEntry entry) : base(entry) { var eventName = Entry.GetString("@0"); Event = Enum.Parse <AsyncEvent>(eventName); }
/// <summary> /// Creates a instance of <see cref="MariWebSocketService"/> /// </summary> public MariWebSocketService() { _onOpen = new AsyncEvent <OpenEventArgs>(); _onError = new AsyncEvent <ErrorEventArgs>(); _onDisconnected = new AsyncEvent <DisconnectEventArgs>(); _onMessage = new AsyncEvent <MessageEventArgs>(); }
/// <summary> /// 回调函数得到异步线程的返回结果 /// </summary> /// <param name="iasync"></param> public void CallBack(IAsyncResult iasync) { if (AsyncEvent.CallBack <int>(iasync) > 0) { //MessageBox.Show("成功"); } }
private static void Queue(AsyncEvent <Message, EventData> e, EventData data, Message m) { if (e != null) { EventQueue.Enqueue(new EventDispatcher(e, data, m)); } }
public WebSocketClient() { this._on_connect = new AsyncEvent(this.EventErrorHandler, "WS_CONNECT"); this._on_disconnect = new AsyncEvent <SocketCloseEventArgs>(this.EventErrorHandler, "WS_DISCONNECT"); this._on_message = new AsyncEvent <SocketMessageEventArgs>(this.EventErrorHandler, "WS_MESSAGE"); this._on_error = new AsyncEvent <SocketErrorEventArgs>(null, "WS_ERROR"); }
public static async Task Run() { var ae = new AsyncEvent <int>(12); await ae.Subscribe(_owner, OnAeChanged1); Console.WriteLine("Subscribe 1"); await ae.Subscribe(_owner, OnAeChanged2); Console.WriteLine("Subscribe 2"); await ae.Subscribe(_owner, OnAeChanged3); Console.WriteLine("Subscribe 3"); await ae.Invoke(13); await ae.Unsubscribe(_owner, OnAeChanged1); Console.WriteLine("Unubscribe 1"); await ae.Invoke(14); await ae.Unsubscribe(_owner); Console.WriteLine("Unubscribe owner"); await ae.Invoke(15); }
public AmongUsGame(AsyncExecutor async, ILoggerFactory loggerFactory) { this.Async = async; this.Logger = loggerFactory.CreateLogger <AmongUsGame>(); this._gameStarted = new AsyncEvent <AmongUsGame, GameStartAsyncEventArgs>("AMONGUS_GAME_STARTED", TimeSpan.Zero, this.AsyncEventExceptionHandler); this._gameEnded = new AsyncEvent <AmongUsGame, GameEndAsyncEventArgs>("AMONGUS_GAME_ENDED", TimeSpan.Zero, this.AsyncEventExceptionHandler); this._playerJoined = new AsyncEvent <AmongUsGame, PlayerAsyncEventArgs>("AMONGUS_PLAYER_JOINED", TimeSpan.Zero, this.AsyncEventExceptionHandler); this._playerLeft = new AsyncEvent <AmongUsGame, PlayerAsyncEventArgs>("AMONGUS_PLAYER_LEFT", TimeSpan.Zero, this.AsyncEventExceptionHandler); this._playerDied = new AsyncEvent <AmongUsGame, PlayerAsyncEventArgs>("AMONGUS_PLAYER_DIED", TimeSpan.Zero, this.AsyncEventExceptionHandler); this._meetingStarted = new AsyncEvent <AmongUsGame, MeetingStartAsyncEventArgs>("AMONGUS_MEETING_STARTED", TimeSpan.Zero, this.AsyncEventExceptionHandler); this._meetingEnded = new AsyncEvent <AmongUsGame, MeetingEndAsyncEventArgs>("AMONGUS_MEETING_ENDED", TimeSpan.Zero, this.AsyncEventExceptionHandler); this.Process = GameProcess.Attach(); this.Process.GameStarted += this.Process_GameStarted; this.Process.GameEnded += this.Process_GameEnded; this.Process.PlayerJoined += this.Process_PlayerJoined; this.Process.PlayerLeft += this.Process_PlayerLeft; this.Process.PlayerDied += this.Process_PlayerDied; this.Process.MeetingStarted += this.Process_MeetingStarted; this.Process.MeetingEnded += this.Process_MeetingEnded; }
/// <summary> /// Executes the asynchronous event processor. /// </summary> private void RunAsyncEventProvider() { var waitHandles = new WaitHandle[] { _newEvent, _shutdown }; while (waitHandles[WaitHandle.WaitAny(waitHandles)] != _shutdown) { AsyncEvent asyncEvent = null; do { lock (_eventQueue) { asyncEvent = _eventQueue.Count > 0 ? _eventQueue.Dequeue() : null; } if (asyncEvent != null) { try { this.Trace("Raising event '{0}' by invoking '{1}'.", asyncEvent.EventName, asyncEvent.EventMethod.Method.Name); asyncEvent.EventMethod.DynamicInvoke(asyncEvent.Parameters); } catch (Exception ex) { this.Error("Raising event '{0}' by invoking '{1}' failed!", ex, asyncEvent.EventName, asyncEvent.EventMethod.Method.Name); } } }while (asyncEvent != null); } _eventThread = null; _eventQueue.Clear(); _newEvent.Dispose(); _shutdown.Dispose(); }
/// <summary> /// Creates a new Eventwaiter object. /// </summary> /// <param name="client">Your DiscordClient</param> public ReactionCollector(DiscordClient client) { this._client = client; var tinfo = this._client.GetType().GetTypeInfo(); this._requests = new ConcurrentHashSet <ReactionCollectRequest>(); // Grabbing all three events from client var handler = tinfo.DeclaredFields.First(x => x.FieldType == typeof(AsyncEvent <DiscordClient, MessageReactionAddEventArgs>)); this._reactionAddEvent = (AsyncEvent <DiscordClient, MessageReactionAddEventArgs>)handler.GetValue(this._client); this._reactionAddHandler = new AsyncEventHandler <DiscordClient, MessageReactionAddEventArgs>(this.HandleReactionAdd); this._reactionAddEvent.Register(this._reactionAddHandler); handler = tinfo.DeclaredFields.First(x => x.FieldType == typeof(AsyncEvent <DiscordClient, MessageReactionRemoveEventArgs>)); this._reactionRemoveEvent = (AsyncEvent <DiscordClient, MessageReactionRemoveEventArgs>)handler.GetValue(this._client); this._reactionRemoveHandler = new AsyncEventHandler <DiscordClient, MessageReactionRemoveEventArgs>(this.HandleReactionRemove); this._reactionRemoveEvent.Register(this._reactionRemoveHandler); handler = tinfo.DeclaredFields.First(x => x.FieldType == typeof(AsyncEvent <DiscordClient, MessageReactionsClearEventArgs>)); this._reactionClearEvent = (AsyncEvent <DiscordClient, MessageReactionsClearEventArgs>)handler.GetValue(this._client); this._reactionClearHandler = new AsyncEventHandler <DiscordClient, MessageReactionsClearEventArgs>(this.HandleReactionClear); this._reactionClearEvent.Register(this._reactionClearHandler); }
internal VoiceNextConnection(DiscordClient client, DiscordGuild guild, DiscordChannel channel, VoiceNextConfiguration config, VoiceServerUpdatePayload server, VoiceStateUpdatePayload state) { this.Discord = client; this.Guild = guild; this.Channel = channel; #if !NETSTANDARD1_1 this.TransmittingSSRCs = new ConcurrentDictionary <uint, AudioSender>(); #endif this._userSpeaking = new AsyncEvent <UserSpeakingEventArgs>(this.Discord.EventErrorHandler, "VNEXT_USER_SPEAKING"); this._userJoined = new AsyncEvent <VoiceUserJoinEventArgs>(this.Discord.EventErrorHandler, "VNEXT_USER_JOINED"); this._userLeft = new AsyncEvent <VoiceUserLeaveEventArgs>(this.Discord.EventErrorHandler, "VNEXT_USER_LEFT"); #if !NETSTANDARD1_1 this._voiceReceived = new AsyncEvent <VoiceReceiveEventArgs>(this.Discord.EventErrorHandler, "VNEXT_VOICE_RECEIVED"); #endif this._voiceSocketError = new AsyncEvent <SocketErrorEventArgs>(this.Discord.EventErrorHandler, "VNEXT_WS_ERROR"); this.TokenSource = new CancellationTokenSource(); this.Configuration = config; this.Opus = new Opus(this.AudioFormat); //this.Sodium = new Sodium(); this.Rtp = new Rtp(); this.ServerData = server; this.StateData = state; var eps = this.ServerData.Endpoint; var epi = eps.LastIndexOf(':'); var eph = string.Empty; var epp = 80; if (epi != -1) { eph = eps.Substring(0, epi); epp = int.Parse(eps.Substring(epi + 1)); } else { eph = eps; } this.WebSocketEndpoint = new ConnectionEndpoint { Hostname = eph, Port = epp }; this.ReadyWait = new TaskCompletionSource <bool>(); this.IsInitialized = false; this.IsDisposed = false; this.PlayingWait = null; this.PacketQueue = new ConcurrentQueue <VoicePacket>(); this.KeepaliveTimestamps = new ConcurrentDictionary <ulong, long>(); this.PauseEvent = new AsyncManualResetEvent(true); this.UdpClient = this.Discord.Configuration.UdpClientFactory(); this.VoiceWs = this.Discord.Configuration.WebSocketClientFactory(this.Discord.Configuration.Proxy); this.VoiceWs.Disconnected += this.VoiceWS_SocketClosed; this.VoiceWs.MessageReceived += this.VoiceWS_SocketMessage; this.VoiceWs.Connected += this.VoiceWS_SocketOpened; this.VoiceWs.Errored += this.VoiceWs_SocketErrored; }
/// <summary> /// Instantiates a new WebSocket client with specified proxy settings. /// </summary> /// <param name="proxy">Proxy settings for the client.</param> public WebSocketClient(IWebProxy proxy) : base(proxy) { _on_connect = new AsyncEvent(EventErrorHandler, "WS_CONNECT"); _on_disconnect = new AsyncEvent <SocketCloseEventArgs>(EventErrorHandler, "WS_DISCONNECT"); _on_message = new AsyncEvent <SocketMessageEventArgs>(EventErrorHandler, "WS_MESSAGE"); _on_error = new AsyncEvent <SocketErrorEventArgs>(null, "WS_ERROR"); }
public MouseHooker() { _proc = HookCallback; _hookID = SetHook(_proc); _LowLevelMouseEvent = new AsyncEvent <LowLevelMouseEventArgs>(EventErrorHandler, "LowLevelMouseEvent"); }
public FFMemoryReader() { _ExclusionWindowHandlers = new List <IntPtr>(); _FFxivChat = new ConcurrentQueue <FFChatMsg>(); _FFWindowStateChanged = new AsyncEvent <WindowStateChangeEventArgs>(EventErrorHandler, "FFWindowStateChanged"); _FFChatMessageArrived = new AsyncEvent <ChatMessageArrivedEventArgs>(EventErrorHandler, "FFChatMessageArrived"); }
private YearsView(DateTime start) { MainGrid = YearsGrid.CreateInstance(start); YearTapped = new AsyncEvent <DateTime>(); MainGrid.YearTapped.Handle(date => YearTapped.Raise(date)); StartDate = start; Add(MainGrid); }
public void Restore(AsyncEvent <T> src) { src.handlers.Clear(); foreach (var pair in handlers) { src.handlers.Add(pair.Key, pair.Value); } }
public static async Task InvokeAsync <T>(this AsyncEvent <Func <T, Task> > eventHandler, T arg) { var subscribers = eventHandler.Subscriptions; for (int i = 0; i < subscribers.Count; i++) { await subscribers[i].Invoke(arg).ConfigureAwait(false); } }
public static void StopListening(NetworkEventType eventType, UnityAction <InputDataHolder> listener) { AsyncEvent thisEvent = null; if (instance.eventDictionary.TryGetValue(eventType, out thisEvent)) { thisEvent.RemoveListener(listener); } }
public static async Task InvokeAsync <T1, T2, T3, T4, T5>(this AsyncEvent <Func <T1, T2, T3, T4, T5, Task> > eventHandler, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { var subscribers = eventHandler.Subscriptions; for (int i = 0; i < subscribers.Count; i++) { await subscribers[i].Invoke(arg1, arg2, arg3, arg4, arg5).ConfigureAwait(false); } }
public static async Task InvokeAsync <T>(this AsyncEvent <Func <T, Task> > eventHandler, T arg) { var subscribers = eventHandler.Subscriptions; foreach (var t in subscribers) { await t.Invoke(arg).ConfigureAwait(false); } }
public LavalinkService(DiscordClient client) { Discord = client; Discord.Ready += Client_Ready; _trackException = new AsyncEvent <LavalinkGuildConnection, TrackExceptionEventArgs>( $"{Program.Settings.Name.ToUpperInvariant()}_LAVALINK_TRACK_EXCEPTION", TimeSpan.Zero, EventExceptionHandler); }
/// <summary> /// Initializes a new instance of the <see cref="AsyncEventOperation"/> class. /// </summary> /// <param name="asyncEvent">The asynchronous event.</param> /// <param name="poolHandler">The pool handler.</param> /// <param name="eventLog">The event log.</param> public AsyncEventOperation(AsyncEvent asyncEvent, IAsyncEventExecutionEngine poolHandler, IMyEventLog eventLog) : base("AsyncEventOperation", eventLog) { AsyncEventOperation asyncEventOperation = this; this.AsyncEvent = asyncEvent; this._poolHander = poolHandler; this._eventAction = operation => asyncEventOperation.ReuseResource = !(asyncEventOperation._poolHander.ProcessAsyncEvent(asyncEvent) is AsyncInProgressResult); }
private static AsyncEvent StreamCopy(Stream src, Stream dst, Func<bool> assertContinuation, Action onException = null, Action<int> onProgress = null) { var evt = new AsyncEvent(false, false); var exception = false; AsyncCallback cb = null; cb = (ar) => { var count = src.EndRead(ar); var readed = (byte[])ar.AsyncState; if (exception) return; if (count != 0) { lock (evt) { if (exception) return; var newArray = new byte[BLOCK_SIZE]; if (!assertContinuation()) return; if (onProgress != null) onProgress(count); src.BeginRead(newArray, 0, BLOCK_SIZE, cb, newArray); try { dst.Write(readed, 0, count); } catch (Exception e) { exception = true; if(onException != null) onException(); } } } else { lock (evt) { src.Close(); evt.Set(); } } }; var startBuffer = new byte[BLOCK_SIZE]; src.BeginRead(startBuffer, 0, BLOCK_SIZE, cb, startBuffer); return evt; }
/// <summary> /// Internals the execute. /// </summary> /// <param name="asyncEvent">The asynchronous event.</param> /// <returns></returns> protected override AsyncHandlerResult InternalExecute(AsyncEvent asyncEvent) { return new AsyncFailedResult(-2147204349, "异步作业类型'{0}'没有被正确识别其对应的类型。", asyncEvent.OperationType); }
private static void Queue(AsyncEvent<Message, EventData> e, EventData data, Message m) { if (e != null) EventQueue.Enqueue(new EventDispatcher(e, data, m)); }
public EventDispatcher(AsyncEvent<Message, EventData> e, EventData eventData, Message senderMessage) { AsyncEvent = e; EventData = eventData; SenderMessage = senderMessage; }