Thanks for that - in the meantime I think I've found the problem but I'll check the profiler out anyway as I could do with knowing about it for the future. What I did is added a textbox and copious debugging comments and I found out it's a Regex.Match method that's hanging it (or at least taking so much CPU to do the match that it stops the app responding) so now I want to be able to limit the time the Regex takes to work if that's possible. I'm not sure how you'd go about it - sort of saying "if the match hasn't completed in 1 second then quit and return no match" - can anyone think of a way to do this? Would a thread be the only way? The Regrx code is below and is searching chuncks of HTML for email addresses and URLs. The HTML is scraped from a client's site and it's only a subset of the whole page's HTML (I extract the HTML between two tags where the emails/urls should be then pass that to the match method) and this seems to be what is causing the Match method to loop.... obviously certain extracts of HTML are just not liked by the Regex engine. //Use the specified regex pattern to find email addresses in the spcified HTML. public string[] FindEmailAndURLAddresses(string strHTML,string strRegex) { string strURLRegex = @"(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?"; string strEmailRegex = @"[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})"; string[] strResults = new string[2]; Regex re = new Regex(strURLRegex,RegexOptions.IgnoreCase); // Match the regular expression URL pattern against the HTML. Match m = re.Match(strHTML); if (m.Success) strResults[1] = m.Groups[0].Value; else strResults[1] = "N/A"; m = null; re = new Regex(strEmailRegex,RegexOptions.IgnoreCase); // Match the regular expression email pattern against the HTML. Match mx = re.Match(strHTML); if (mx.Success) strResults[0] = mx.Groups[0].Value; else strResults[0] = "N/A"; mx = null; return strResults; } Hope soneone can suggest something to help out here... not too sure how to control this so it doesn't go into an endless loop! Mike |