private void OnSubmitQueueBufferReady(object sender, BufferReadyEventArgs <CmppSmsServerSubmitContext> e) { var q = e.Queue; var concurrency = Environment.ProcessorCount * 4; var templateUri = "http://localhost:52763/api/sms/v1/sa?t={0}&n={1}&ref={2}&m={3}"; var token = HttpUtility.UrlEncode("SucTNuRL+b950nUuI0gYpQ"); var client = new HttpClient(); Parallel.For(0, concurrency, (ticket) => { CmppSmsServerSubmitContext context = null; while (e.Queue.TryDequeue(out context)) { var submit = context.Submit; var reference = string.Format("CMPP:{0},ID:{1}", context.MessageId, context.UserId); var url = string.Format(templateUri, token, submit.ReceiverTerminalIds[0], reference, submit.Content); try { var t = client.GetStringAsync(url); t.Wait(); } catch { }; } }); //end parallel }
private void OnNotifyQueueBufferReady(object sender, BufferReadyEventArgs <CmppMessageReport> e) { var session = this.Session; var q = e.Queue; var concurrency = this.ConcurrencyLevel; if (concurrency <= 0) { concurrency = Environment.ProcessorCount; } Parallel.For(0, concurrency, (ticket) => { CmppMessageReport report = null; while (e.Queue.TryDequeue(out report)) { try { var t = session.SendCmppReportAsync(report); t.Wait(); } catch { } } }); }
void PdBufferReady(object sender, BufferReadyEventArgs args) { float[] newSamples = args.Output; _circularBuffer.Write(PcmFromFloat(newSamples), 0, newSamples.Length * 4); RefillBuffer(); }