// Get the information about the asset and displays it
        public void ShowAsset( IVRBranch branch )
        {
            AssetDatas assetDatas = new AssetDatas( branch );

            if( _currentAssetView == null )
            {
                _currentAssetView = ( AssetView )AssetDatasViewer.CurrentViewer.UI.OpenForm( typeof( AssetView ) );
                _currentAssetView.FormClosing += new FormClosingEventHandler( assetView_Closed );
            }

            mDeleg_DocumentsAndScada = new Deleg( _service.GetAssetDocumentsAndScada );
            AsyncCallback callback_DocumentsAndScada = new AsyncCallback( buildAssetView );
            mDeleg_DocumentsAndScada.BeginInvoke( assetDatas, callback_DocumentsAndScada, null );
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            //创建一个委托
            Deleg proc = new Deleg(WriteSum);

            //采用异步方式调用委托
            //指定SumDone为异步操作完成后的回调函数
            //指定ev为object参数,用于同步回调函数与主线程间操作
            IAsyncResult async = proc.BeginInvoke(10, 20, SumDone, ev);
            Console.WriteLine("主线程ID号为:{0},异步操作已开始执行,正等待操作完成。", Thread.CurrentThread.ManagedThreadId);

            //等待异步操作完成
            ev.WaitOne();
            Console.WriteLine("异步操作已完成!");

            System.Console.ReadKey();
        }