IChannel::ChannelPriority Property
Gets the priority of the channel.
Assembly: mscorlib (in mscorlib.dll)
| Exception | Condition |
|---|---|
| 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 = 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 ); }
for operating with infrastructure code. Demand value: SecurityAction::LinkDemand; Permission value: SecurityPermissionFlag::Infrastructure
Available since 1.1