Sql Server : Connection Timeout v/s Command Timeout

Sql server provides two types of timeouts, thought they look same there is a huge difference between then

  • Connection Timeout

Connection timeout is the number of seconds to wait n try to get a connection to sql server. Default is 15 seconds. You can modify it using connection string. Use property **Connection Timeout = 30;**

Read more about it here

 

  • Command Timeout

Command timeout is the number of second to wait for completion of query execution. The default is 30 seconds. You can set it using **.Timeout()** method in dbContext.

Read more about it here

 

Comments in Code

In an ideal code comments have no places.

  • They make code look ugly. Even makes it unreadable.
  • Too many comments makes it difficult to navigate code.
  • They almost always convey outdated information. With outdated information, they might become confusing.
  • One needs to read same code line twice. And the need to remember extra information while understanding the code.

Think, why should one write a comment? To tell certain information about

  • a particular line of code
  • about a block of code.

Can we express the same information via code.

  • One should name the variable appropriately.
  • Refactor a block of code in a separate method.

One more place where you will see comments is around the code which is no longer relevant. What should one do about such comments? JUST DELETE IT. Yes, just delete it. Version Control Systems remember it for you. Add if you want it work on it, just write TODO for it.

Happy Coding.

 

 

IIS AppDomain, Application Pool and Worker Process

There are 3 things involved when hosting an application in IIS.

App Domain

In a server you can have many asp.net sites that runs together. Each one site is an app domain.

App Pool

You must assign to each of them one application pool. Many AppDomains (sites) can have the same application pool, and because they have the same application pool they run under the same processes, and under the same account – and they have the same settings of the pool. If this pool restarts, then all sites under that pools restarts.

Worker Process

Now each pool can have one or more worker process. Each worker process is a different program that run’s your site, have their alone static variables, they different start stop calls etc. Different worker process are not communicate together, and the only way to exchange data is from common files or a common database. If you have more than one worker process and one of them make long time calculations, then the other can take care to handle the internet calls and show content.

Resharper not running unit tests

I had an issue with ReSharper where it was running my unit tests sometimes and not always. I am using Resharper 9 and VS2013. It was working fine, but suddenly stopped. ReSharper’s unit test window stayed grey, the spinning icon endlessly.

Tried things like restarting Visual Studio, rebuilding solution, running Visual Studio in administration mode and even restarting my computer but I was still not closer to getting my unit tests running.

Eventually I cleared ReSharper cache using ReSharper’s options (Resharper > Options > Environment > General > Clear Cache), and after clearing ReSharper’s cache and restarting Visual Studio I was able to run my unit tests once again.