Setting Default Global Timeout for Regular expressions

In my previous post, I mentioned about the capability of specifying a Timeout while executing a Regular expression. Sometimes, when your application is totally developed, and it would be a heck to change every single code which uses regular expression to specify a timeout. Sometimes the Regular expression is parsed inside an external assembly. In such cases, you can set a Global Default Timeout per appdomain which will indicate the default timeout of execution per appdomain.

To do this :


The data will specify the Default timeout for every regular expression running on the current Appdomain to be 200 milliseconds.

The Default timeout can be overridden by specifying another timeout when calling the Regex.

I hope this would come helpful.

Thanks for reading

Abhishek Sur

Abhishek Sur is a Microsoft MVP since year 2011. He is an architect in the .NET platform. He has profound theoretical insight and years of hands on experience in different .NET products and languages. He leads the Microsoft User Group in Kolkata named KolkataGeeks, and regularly organizes events and seminars in various places for spreading .NET awareness. He is associated with the Microsoft Insider list on WPF and C#, and is in constant touch with product group teams. He blogs at His Book : Visual Studio 2012 and .NET 4.5 Expert Development Cookbook. Follow Abhishek at Twitter : @abhi2434