SAMPLE: ThreadPriorityChangerSink
These Sinks can be used on the client respectively the server to propagate the Thread.CurrentThread.Priority via remoting boundaries to the server.
Contents
In the ZIP file (which can be downloaded below) you'll find the following three projects:
- Sinks - Contains the client and server-side sinks and providers
- Client - Contains a sample client + testcases
- Server - Contains a sample server
In Sinks.sln you'll find the following two Sinks + respective Providers:
- PriorityEmitterSink - used at the client to transfer the current priority with every method call
- PriorityChangerSink - used at the server to set the current priority if it's contained in the message
Usage
When using the standard compilation to PrioritySinks.dll you should reference this DLL from both, the server and the client. You can then use the following configuration files to enable the sink:
Client-Side:
<configuration>
<system.runtime.remoting>
<application>
<channels>
<channel ref="http">
<clientProviders>
<provider
type="PrioritySinks.PriorityEmitterSinkProvider, PrioritySinks" />
<formatter ref="soap" />
</clientProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
</configuration>Server-Side:
<configuration>
<system.runtime.remoting>
<application>
<channels>
<channel ref="http" port="5555">
<serverProviders>
<formatter ref="soap" />
<provider
type="PrioritySinks.PriorityChangerSinkProvider, PrioritySinks" />
</serverProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
</configuration>Download
You can download this sinks in ZIP format here (90kb ThreadPriorityChangerSink.zip). You might have to adjust some references or (if you just want to play around with it) unzip it to c:\testing.net\ThreadPriorityChangerSink which should leave the references intact ...
Disclaimer/Issues
This is sample code to show you some possibilities of .NET Remoting - it's therefore to be considered "educational". This sink does not support asynchronous calls. Be sure to fully understand the example before using parts of the code in your projects.
This sink comes without warranty of any kind.