Click here to Skip to main content
15,912,328 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
Here is the program which collects email id in bunch of documents.
it extracting the email ids correctly but it hang after some time.
here is the code
string strmatch = string.Empty;
string strPattern = string.Empty;
Regex rxPattern = null;
MatchCollection Mcoll = null;
strPattern = GetEmailPattern();
if (strPattern.Trim() != "")
{
rxPattern = new Regex(strPattern, RegexOptions.Compiled);
Mcoll = rxPattern.Matches(strResumeContent);
foreach (Match rxMatch in Mcoll)
{
	strmatch = rxMatch.Value.ToString().Trim();
	if (strmatch != string.Empty && ValidateEmail(strmatch) == true && !IsExistEmailId(strmatch))
	{
	    procMyApp_DisplayFiles(strmatch, strFileWithPath);
	    //Application.DoEvents();
	    procMyApp_StatusMsg("\\ ... " + strFileWithPath,
vsfDisplayEmaillAddress.Rows.Count.ToString(),mlngFileCount);
	}
}

}

This is the Regular expression which i am using to find email address in documents

([a-mo-zA-MO-Z0-9]|((?<!\\\\)(n|N)))+([a-zA-Z0-9\\.\\!\\$\\&\\'\\*\\+\\^_\\`\\{}-]+)*@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*\\.([a-zA-Z]{2,})

The code hangs on the foreach of matchcollection
can anyone help me to overcome the problem
waiting for an solution
regards
kumaran
Posted
Updated 25-Mar-10 18:33pm
v4

are you running this on some secondary thread?
with .NET 1.x or with illegal-thread-crossing-checks disabled?

if double yes, read this[^].

:)
 
Share this answer
 
cross check the IsExistMailId function ...this could be the one hanging your functionality.
 
Share this answer
 
Run it in debug mode. When it "hangs", hit the pause button on the debugger and see what line it is at.

Or, with an example that you know will "hang", set a breakpoint in the program, and go step by step until it hangs.
 
Share this answer
 
Some unassigned variables are used in code, it can be because of that or may be related the functions called in if condition.
 
Share this answer
 
evergreen501 wrote:
string strPattern = string.Empty;
...
rxPattern = new Regex(strPattern, RegexOptions.Compiled);

Is probably your problem...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900