Thursday, October 25, 2012

WCF Performance


Thread pool throttling


Antivirus slowdown

Friday, October 12, 2012

WCF: Windows Communication Foundation

SelfHosting tutorial

http://msdn.microsoft.com/en-us/library/ms731758.aspx

How to publish metadata when using TCP binding:
1. Inside app.config, create service behavior element (e.g. HelloServiceBehavior)
2. Refer the behavior from service tag (behaviorConfiguration="HelloServiceBehavior")
3. Add endpoint to the service to exchange metadata, use contract="IMetadataExchange".
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="HelloServiceBehavior">
                    <serviceMetadata policyVersion="Policy15" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <services>
            <service behaviorConfiguration="HelloServiceBehavior" name="HelloService">
                <endpoint address="net.tcp://localhost:8080/hello" binding="netTcpBinding"
                    bindingConfiguration="" name="HelloService" contract="IHelloService" />
                <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
            </service>
        </services>
    </system.serviceModel>
</configuration>



Using Async/Await



Async Cancellation/Progress is not supported


http://social.msdn.microsoft.com/Forums/en-US/async/thread/b1353952-ce52-4af7-b6ec-f792bef28566/


Enabling trace

netTcpBinding uses binary encoding and transport security, which delivers better performance.
Following URLS will help to get more information

http://stackoverflow.com/questions/665473/how-to-handle-wcf-client-disconnect
http://stackoverflow.com/questions/5338842/detect-socket-disconnect-in-wcf

Reliable Messaging

Need to turn-off or set level to Message Security for Bindings (doesn't work if the level is set to the default Transport level)
Working case
- Server not available during the first connection
- Network cable is blipping
Not working case
- Server is down and restarted

WCF and WebSocket

Monday, October 1, 2012

Linking Boost DLL on Windows

http://stackoverflow.com/questions/2520234/how-to-link-to-dynamic-boost-libs

.NET Async Await

* Performance consideration: http://msdn.microsoft.com/en-us/magazine/hh456402.aspx
* Comparison with old patterns: http://msdn.microsoft.com/en-us/library/jj152938.aspx

,NET timers

Comparisons: http://msdn.microsoft.com/en-us/magazine/cc164015.aspx

Note that System.Timers.Timer and System.Threading.Timer by default call your timer event handler on a worker thread obtained from the common language runtime (CLR) thread pool.



 System.Windows.FormsSystem.TimersSystem.Threading
Timer event runs on what thread?UI threadUI or worker threadWorker thread
Instances are thread safe?NoYesNo
Familiar/intuitive object model?YesYesNo
Requires Windows Forms?YesNoNo
Metronome-quality beat?NoYes*Yes*
Timer event supports state object?NoNoYes
Initial timer event can be scheduled?NoNoYes
Class supports inheritance?YesYesNo
* Depending on the availability of system resources (for example, worker threads)