PeerNameRegistration.Start メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
PeerNameをCloudに登録します。 EndPointCollectionを指定しない場合は、Port プロパティで指定されたポート値と共にアドレスの自動選択が使用されます。
public:
void Start();
[System.Security.SecurityCritical]
public void Start();
[<System.Security.SecurityCritical>]
member this.Start : unit -> unit
Public Sub Start ()
- 属性
例外
PeerName プロパティが null に設定されている。
このオブジェクトには、以前に Dispose() が呼び出されていました。
指定した PeerName は既に登録されています。 登録を更新するには、 Update() メソッドを使用する必要があります。
メッセージまたはデータ要素が無効です。 または、 UseAutoEndPointSelection が設定されておらず、データ BLOB または IPEndPoint が指定されていません。
例
次のコード例では、 PeerName を作成し、指定されたメタデータと共に登録します。
// Creates a PeerName and registers it along with the metadata specified
// The parameters used to register the name are static types that are set
// from user input (command-line or user dialog).
// These parameters include the following:
// static String peerName
// static PeerNameType peerNameType
// static int portNumber
// static String comment
// static Cloud cloudName
public static void CreateAndPublishPeerName()
{
try{
// Creates a the PeerName to register using the classifier and type provided
PeerName peerName = new PeerName(peerNameClassifier, peerNameType);
// Create a registration object which represents the registration
// of the PeerName in a Cloud
PeerNameRegistration peerNameRegistration = new PeerNameRegistration();
peerNameRegistration.PeerName = peerName;
peerNameRegistration.Port = portNumber;
peerNameRegistration.Comment = comment;
peerNameRegistration.Cloud = cloudName;
// Since the peerNameRegistration.EndPointCollection is not specified,
// all (IPv4&IPv6) addresses assigned to the local host will
// automatically be associated with the peerNameRegistration instance.
// This behavior can be control using peerNameRegistration.UseAutoEndPointSelection
//Note: Additional information may be specified on the PeerNameRegistration
// object, which is not shown in this example.
// Starting the registration means the name is published for
// other peers to resolve
peerNameRegistration.Start();
Console.WriteLine("Registration of Peer Name: {0} complete.", peerName.ToString(), cloudName);
Console.WriteLine();
Console.WriteLine("Press any key to stop the registration and close the program");
Console.ReadKey();
// Stopping the registration means the name is no longer published
peerNameRegistration.Stop();
} catch(Exception e){
Console.WriteLine("Error creating and registering the PeerName: {0} \n", e.Message);
Console.WriteLine(e.StackTrace);
}
}
注釈
このメソッドは、 PeerName プロパティで指定されたピア名を、すべてのソース アドレスとコンストラクターで指定された Port に登録します。 既定のポートは、エンドポイントが指定されていない場合にのみ、このメソッドによって使用されます。
Cloud プロパティがnull場合、このメソッドは、Name、Scope、およびScopeIdの既定値を初期化するAvailable フィールドを使用して、PeerName プロパティで指定されたピア名を登録します。
PeerNameRegistration オブジェクトが開始されると、Stop メソッドを使用してオブジェクトを停止します。
登録を更新するには、 Update メソッドを使用する必要があります。