管理オブジェクトに非同期的にバインドします。
Overloads Public Sub Get( _
ByVal watcher As ManagementOperationObserver _)
[C#]
public void Get(ManagementOperationObserverwatcher);
[C++]
public: void Get(ManagementOperationObserver* watcher);
[JScript]
public function Get(
watcher : ManagementOperationObserver);
パラメータ
- watcher
操作の結果をイベントとして受け取るオブジェクト。
解説
メソッドは、オブジェクトを取得する要求を発行してから、すぐに制御を戻します。操作の結果は、提供されたウォッチャー オブジェクトで発生するイベントによって渡されます。
使用例
ManagementObject o = new ManagementObject("MyClass.Name='abc'");
//Set up handlers for asynchronous get
MyHandler h = new MyHandler();
ManagementOperationObserver ob = new ManagementOperationObserver();
ob.Completed += new CompletedEventHandler(h.Done);
//Get the object asynchronously
o.Get(ob);
//Wait until operation is completed
while (!h.Completed)
System.Threading.Thread.Sleep (1000);
//Here we can use the object
Console.WriteLine(o["SomeProperty"]);
public class MyHandler
{
private bool completed = false;
public void Done(object sender, CompletedEventArgs e) {
Console.WriteLine("async Get completed !");
completed = true;
}
public bool Completed {
get {
return completed;
}
}
}
[Visual Basic]
Dim o As New ManagementObject("MyClass.Name=""abc""")
'Set up handlers for asynchronous get
Dim h As New MyHandler()
Dim ob As New ManagementOperationObserver()
ob.Completed += New CompletedEventHandler(h.Done)
'Get the object asynchronously
o.Get(ob)
'Wait until operation is completed
While Not h.Completed
System.Threading.Thread.Sleep(1000)
End While
'Here we can use the object
Console.WriteLine(o("SomeProperty"))
Public Class MyHandler
Private _completed As Boolean = false;
Public Sub Done(sender As Object, e As EventArrivedEventArgs)
Console.WriteLine("async Get completed !")
_completed = True
End Sub
Public ReadOnly Property Completed() As Boolean
Get
Return _completed
End Get
End Property
End Class
[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
.NET Framework セキュリティ:
- 直前の呼び出し元の完全信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細の参照先 : 部分信頼コードからのライブラリの使用
参照
ManagementObject クラス | ManagementObject メンバ | System.Management 名前空間 | ManagementObject.Get オーバーロードの一覧