Exemple #1
0
        /// <summary>
        /// Returns objects that describe the network interfaces.
        /// </summary>
        /// <returns>Error code</returns>
        public PPError UpdateNetworkList()
        {
            Action <PPError, PPResource> callback = new Action <PPError, PPResource>(
                (result, resource) =>
            {
                OnUpdateNetworkList(result, new NetworkList(resource));
            }
                );

            var onUpdateNetworkListCallback = new CompletionCallbackWithOutput <PPResource>(new CompletionCallbackWithOutputFunc <PPResource>(callback));

            return((PPError)PPBNetworkMonitor.UpdateNetworkList(this, out onUpdateNetworkListCallback.OutputAdapter.output, onUpdateNetworkListCallback));
        }
Exemple #2
0
        private async Task <NetworkListInfo> UpdateNetworkListAsyncCore(MessageLoop messageLoop = null)
        {
            var tcs = new TaskCompletionSource <NetworkListInfo>();
            EventHandler <NetworkListInfo> handler = (s, e) => { tcs.TrySetResult(e); };

            try
            {
                HandleUpdateNetworkList += handler;

                if (MessageLoop == null && messageLoop == null)
                {
                    UpdateNetworkList();
                }
                else
                {
                    Action <PPError> action = new Action <PPError>((e) =>
                    {
                        var output = new APIArgumentAdapter <PPResource>();
                        var result = (PPError)PPBNetworkMonitor.UpdateNetworkList(this,
                                                                                  out output.output,
                                                                                  new BlockUntilComplete());

                        tcs.TrySetResult(new NetworkListInfo(result, new NetworkList(output.Output)));
                    }
                                                                   );
                    InvokeHelper(action, messageLoop);
                }
                return(await tcs.Task);
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
                tcs.SetException(exc);
                return(new NetworkListInfo(PPError.Aborted, null));
            }
            finally
            {
                HandleUpdateNetworkList -= handler;
            }
        }
Exemple #3
0
 public NetworkMonitor(Instance instance)
 {
     handle = PPBNetworkMonitor.Create(instance);
 }