IChannel.ChannelPriority Propriedade

Definição

Obtém a prioridade do canal.

public:
 property int ChannelPriority { int get(); };
public int ChannelPriority { get; }
public int ChannelPriority { [System.Security.SecurityCritical] get; }
member this.ChannelPriority : int
[<get: System.Security.SecurityCritical>]
member this.ChannelPriority : int
Public ReadOnly Property ChannelPriority As Integer

Valor da propriedade

Int32

Um inteiro que indica a prioridade do canal.

Atributos

Exceções

O chamador imediato não tem permissão de infraestrutura.

Exemplos

// Creating the 'IDictionary' to set the server object properties.
IDictionary^ myDictionary = gcnew Hashtable;
myDictionary[ "name" ] = "HttpClientChannel";
myDictionary[ "priority" ] = 2;

// Set the properties along with the constructor.
HttpClientChannel^ myHttpClientChannel = gcnew HttpClientChannel( myDictionary,gcnew BinaryClientFormatterSinkProvider );

// Register the server channel.
ChannelServices::RegisterChannel( myHttpClientChannel );
MyHelloServer ^ myHelloServer1 = dynamic_cast<MyHelloServer^>(Activator::GetObject( MyHelloServer::typeid, "http://localhost:8085/SayHello" ));
if ( myHelloServer1 == nullptr )
      System::Console::WriteLine( "Could not locate server" );
else
{
   Console::WriteLine( myHelloServer1->myHelloMethod( "Client" ) );

   // Get the name of the channel.
   Console::WriteLine( "Channel Name :{0}", myHttpClientChannel->ChannelName );

   // Get the channel priority.
   Console::WriteLine( "ChannelPriority :{0}", myHttpClientChannel->ChannelPriority );
   String^ myString;
   String^ myObjectURI1;
   Console::WriteLine( "Parse :{0}{1}", myHttpClientChannel->Parse( "http://localhost:8085/SayHello",  myString ), myString );

   // Get the key count.
   System::Console::WriteLine( "Keys->Count : {0}", myHttpClientChannel->Keys->Count );

   // Get the channel message sink that delivers message to the specified url.
   IMessageSink^ myIMessageSink = myHttpClientChannel->CreateMessageSink( "http://localhost:8085/NewEndPoint", nullptr,  myObjectURI1 );
   Console::WriteLine( "The channel message sink that delivers the messages to the URL is : {0}", myIMessageSink );
   Console::WriteLine( "URI of the new channel message sink is: {0}", myObjectURI1 );
}
// Creating the 'IDictionary' to set the server object properties.
IDictionary myDictionary = new Hashtable();
myDictionary["name"]="HttpClientChannel";
myDictionary["priority"]=2;
// Set the properties along with the constructor.
HttpClientChannel myHttpClientChannel =
      new HttpClientChannel(myDictionary,new BinaryClientFormatterSinkProvider());
// Register the server channel.
ChannelServices.RegisterChannel(myHttpClientChannel);
MyHelloServer myHelloServer1 = (MyHelloServer)Activator.GetObject(
typeof(MyHelloServer), "http://localhost:8085/SayHello");
if (myHelloServer1 == null)
   {
       System.Console.WriteLine("Could not locate server");
   }
   else
{
   Console.WriteLine(myHelloServer1.myHelloMethod("Client"));
   // Get the name of the channel.
   Console.WriteLine("Channel Name :"+myHttpClientChannel.ChannelName);
   // Get the channel priority.
   Console.WriteLine("ChannelPriority :"+myHttpClientChannel.ChannelPriority.ToString());
   string myString,myObjectURI1;
   Console.WriteLine("Parse :" +
       myHttpClientChannel.Parse("http://localhost:8085/SayHello",out myString)+myString);
   // Get the key count.
   System.Console.WriteLine("Keys.Count : " + myHttpClientChannel.Keys.Count);
   // Get the channel message sink that delivers message to the specified url.
   IMessageSink myIMessageSink =
   myHttpClientChannel.CreateMessageSink("http://localhost:8085/NewEndPoint",
                                                                   null,out myObjectURI1);
   Console.WriteLine("The channel message sink that delivers the messages to the URL is : "
                           +myIMessageSink.ToString());
   Console.WriteLine("URI of the new channel message sink is: " +myObjectURI1);
}
  ' Creating the 'IDictionary' to set the server object properties.
  Dim myDictionary As  New Hashtable()
  myDictionary("name") = "HttpClientChannel"
  myDictionary("priority") = 2
  ' Set the properties along with the constructor.
Dim myHttpClientChannel As New _
          HttpClientChannel( myDictionary, New BinaryClientFormatterSinkProvider)
  ' Register the server channel.
  ChannelServices.RegisterChannel(myHttpClientChannel)
  Dim myHelloServer1 As MyHelloServer = CType(Activator.GetObject(GetType(MyHelloServer), _
          "http://localhost:8085/SayHello"), MyHelloServer)
  If myHelloServer1 Is Nothing Then
     System.Console.WriteLine("Could not locate server")
  Else
     Console.WriteLine(myHelloServer1.myHelloMethod("Client"))
     ' Get the name of the channel.
     Console.WriteLine("Channel Name :" + myHttpClientChannel.ChannelName)
     ' Get the channel priority.
     Console.WriteLine("ChannelPriority :" + myHttpClientChannel.ChannelPriority.ToString())
     Dim myString, myObjectURI1 As String
     Console.WriteLine("Parse :" + _
          myHttpClientChannel.Parse("http://localhost:8085/SayHello", myString) + myString)
     ' Get the key count.
     System.Console.WriteLine("Keys.Count : " + myHttpClientChannel.Keys.Count.ToString())
     ' Get the channel message sink that delivers message to the specified url.
     Dim myIMessageSink As IMessageSink =myHttpClientChannel.CreateMessageSink( _
          "http://localhost:8085/NewEndPoint", Nothing, myObjectURI1)
   Console.WriteLine("The channel message sink that delivers the messages to the URL is :" + _
           CType(myIMessageSink, Object).ToString)
   Console.WriteLine("URI of the new channel message sink is: " + myObjectURI1)
  End If

Comentários

Números mais altos indicam prioridade mais alta, portanto, um canal com prioridade 50 tem uma prioridade maior do que um canal com prioridade 25. O canal de domínio entre aplicativos tem uma prioridade de 100.

Os canais cliente com prioridade mais alta têm a primeira chance de se conectar a um objeto remoto especificado por uma URL ou uma entrada de dados de canal específica de um ObjRef.

Para canais de servidor, a prioridade indica a ordem na qual seus dados de canal serão exibidos em um ObjRef, o que, por sua vez, afeta a ordem na qual os clientes tentarão se conectar ao objeto do servidor. Se o servidor estiver escutando em um canal HTTP com prioridade 50 e um canal TCP com prioridade 25 e o cliente tiver registrado um canal HTTP e TCP, o cliente usará o canal HTTP para falar com o servidor.

Aplica-se a

Confira também