IChannel.ChannelPriority Property

Gets the priority of the channel.

Namespace:  System.Runtime.Remoting.Channels
Assembly:  mscorlib (in mscorlib.dll)

int ChannelPriority { get; }

Property Value

Type: System.Int32
An integer that indicates the priority of the channel.

ExceptionCondition
SecurityException

The immediate caller does not have infrastructure permission.

Higher numbers indicate higher priority, so a channel with priority of 50 has a higher priority than a channel with priority 25. The cross application domain channel has a priority of 100.

Client channels with higher priority are given the first chance to connect to a remote object specified by a URL or a particular channel data entry from a ObjRef.

For server channels, the priority indicates the order in which their channel data will appear in a ObjRef, which in turn affects the order in which clients will try to connect to the server object. If the server is listening on an HTTP channel with priority 50 and a TCP channel with priority 25 and the client has registered both an HTTP and TCP channel, then the client will use the HTTP channel to talk to the server.

// 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.
IDictionary* myDictionary = new Hashtable();
myDictionary->Item[S"name"]=S"HttpClientChannel";
myDictionary->Item[S"priority"]=__box(2);
// Set the properties along with the constructor.
HttpClientChannel* myHttpClientChannel = 
   new HttpClientChannel(myDictionary,new BinaryClientFormatterSinkProvider());
// Register the server channel.
ChannelServices::RegisterChannel(myHttpClientChannel);
MyHelloServer* myHelloServer1 = dynamic_cast<MyHelloServer*>(Activator::GetObject(__typeof(MyHelloServer), S"http://localhost:8085/SayHello"));
if (myHelloServer1 == 0)
   System::Console::WriteLine(S"Could not locate server");
else
{
   Console::WriteLine(myHelloServer1->myHelloMethod(S"Client"));
   // Get the name of the channel.
   Console::WriteLine(S"Channel Name :{0}", myHttpClientChannel->ChannelName);
   // Get the channel priority.
   Console::WriteLine(S"ChannelPriority :{0}", __box(myHttpClientChannel->ChannelPriority));
   String* myString;
   String* myObjectURI1;

   Console::WriteLine(S"Parse :{0}{1}", myHttpClientChannel->Parse(S"http://localhost:8085/SayHello", &myString), myString);
   // Get the key count.
   System::Console::WriteLine(S"Keys->Count : {0}", __box(myHttpClientChannel->Keys->Count));
   // Get the channel message sink that delivers message to the specified url.
   IMessageSink* myIMessageSink = 
      myHttpClientChannel->CreateMessageSink(S"http://localhost:8085/NewEndPoint", 
      0,&myObjectURI1);
   Console::WriteLine(S"The channel message sink that delivers the messages to the URL is : {0}", myIMessageSink);
   Console::WriteLine(S"URI of the new channel message sink is: {0}", myObjectURI1);
}

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft