示例#1
0
        public override IAsyncResult BeginCreatePortMap(Mapping mapping, AsyncCallback callback, object asyncState)
        {
            PortMapAsyncResult pmar = new PortMapAsyncResult(mapping.Protocol, mapping.PublicPort, PmpConstants.DefaultLeaseTime, callback, asyncState);

            ThreadPool.QueueUserWorkItem(delegate {
                try {
                    CreatePortMap(pmar.Mapping, true);
                    pmar.Complete();
                } catch (Exception e) {
                    pmar.Complete(e);
                }
            });
            return(pmar);
        }
示例#2
0
        public override IAsyncResult BeginDeletePortMap(Mapping mapping, AsyncCallback callback, object asyncState)
        {
            PortMapAsyncResult pmar = new PortMapAsyncResult(mapping, callback, asyncState);

            ThreadPool.QueueUserWorkItem(delegate {
                try {
                    CreatePortMap(pmar.Mapping, false);
                    pmar.Complete();
                } catch (Exception e) {
                    pmar.Complete(e);
                }
            });
            return(pmar);
        }
示例#3
0
        public override void EndDeletePortMap(IAsyncResult result)
        {
            PortMapAsyncResult pmar = result as PortMapAsyncResult;

            pmar.AsyncWaitHandle.WaitOne();
        }
示例#4
0
        void EndCreatePortMap(IAsyncResult result)
        {
            PortMapAsyncResult pmar = result as PortMapAsyncResult;

            pmar.AsyncWaitHandle.WaitOne();
        }