Hi we have an application that lets people provide a regular expression via an textbox and then processes some text using the C# regex class. The problem we have right now is that sometimes users can put in regex that take a long time and the app just hanges. We would as a result like to have a way to let a C# regex timeout.
The deliverable for the project is a class called RegexWT. This class should have the same methods as Regex (and even possibly inherhit from Regex) save for that the worker methods like Match and Replace provide an addition long parameter called "timeout" which allows you to specify a timeout in milliseconds.
In the event that the regex processing goes over the timeout, the call should return.
The usage should be just like Regex:
string regexstr = "[\\s*Mybadregex*;][1]";
RegexWT regexwt = new RegexWT(s, [login to view URL] | [login to view URL] | [login to view URL]);
string temp = "Here is a string to parse";
temp = [login to view URL](temp, "", 30000); //times out after 30 seconds
It would seem after some research that the way to accomplish this is to have something wrap regex and run asynch and then if the operation does not complete kill the thread.
This technique is discussed here:
<[login to view URL]>
## Deliverables
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.
2) Deliverables must be in ready-to-run condition, as follows (depending on the nature of the deliverables):
a) For web sites or other server-side deliverables intended to only ever exist in one place in the Buyer's environment--Deliverables must be installed by the Seller in ready-to-run condition in the Buyer's environment.
b) For all others including desktop software or software the buyer intends to distribute: A software installation package that will install the software in ready-to-run condition on the platform(s) specified in this bid request.
3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement).
## Platform
.net 2.0 (vs2005)
windows xp or better