Exemplo n.º 1
0
        public void WriteReport(HidReport report, WriteCallback callback, int timeout)
        {
            var writeReportDelegate = new WriteReportDelegate(WriteReport);
            var asyncState          = new HidAsyncState(writeReportDelegate, callback);

            writeReportDelegate.BeginInvoke(report, timeout, EndWriteReport, asyncState);
        }
Exemplo n.º 2
0
        public void WriteReport(HidReport report, WriteCallback callback)
        {
            WriteReportDelegate writeReportDelegate = WriteReport;
            HidAsyncState       @object             = new HidAsyncState(writeReportDelegate, callback);

            writeReportDelegate.BeginInvoke(report, EndWriteReport, @object);
        }
Exemplo n.º 3
0
        private static void EndWriteReport(IAsyncResult ar)
        {
            HidAsyncState       hidAsyncState       = (HidAsyncState)ar.AsyncState;
            WriteReportDelegate writeReportDelegate = (WriteReportDelegate)hidAsyncState.CallerDelegate;
            WriteCallback       writeCallback       = (WriteCallback)hidAsyncState.CallbackDelegate;
            bool success = writeReportDelegate.EndInvoke(ar);

            writeCallback?.Invoke(success);
        }
Exemplo n.º 4
0
        public async Task <bool> WriteReportAsync(HidReport report, int timeout = 0)
        {
            var writeReportDelegate = new WriteReportDelegate(WriteReport);

#if NET20 || NET35
            return(await Task <bool> .Factory.StartNew(() => writeReportDelegate.Invoke(report, timeout)));
#else
            return(await Task <bool> .Factory.FromAsync(writeReportDelegate.BeginInvoke, writeReportDelegate.EndInvoke, report, timeout, null));
#endif
        }
Exemplo n.º 5
0
        public async Task <bool> WriteReportAsync(HidReport report, int timeout = 0)
        {
            var writeReportDelegate = new WriteReportDelegate(WriteReport);

            return(await Task <bool> .Factory.FromAsync(writeReportDelegate.BeginInvoke, writeReportDelegate.EndInvoke, report, timeout, null));
        }
Exemplo n.º 6
0
 public void WriteReport(HidReport report, WriteCallback callback)
 {
     var writeReportDelegate = new WriteReportDelegate(WriteReport);
     var asyncState = new HidAsyncState(writeReportDelegate, callback);
     writeReportDelegate.BeginInvoke(report, EndWriteReport, asyncState);
 }
Exemplo n.º 7
0
 public async Task<bool> WriteReportAsync(HidReport report, int timeout = 0)
 {
     var writeReportDelegate = new WriteReportDelegate(WriteReport);
     return await Task<bool>.Factory.FromAsync(writeReportDelegate.BeginInvoke, writeReportDelegate.EndInvoke, report, timeout, null);
 }