I am new to WatiN but made a few applications, and it's quite good. The problem is that my program is not responding while performing some web actions.
Here is my source code of WatiN:
using (var ie = new IE())
{
StreamWriter wr = new StreamWriter(textBox1.Text+".txt");
ie.GoTo("http://twitter.com/"+textBox1.Text+"/followers");
string dm1 = ie.Body.Parent.OuterHtml;
Match match1 = Regex.Match(dm1, "(?<=<strong>).*?(?=</strong> Followers)");
string ck = match1.ToString();
ck = ck.Replace(",", "");
long check = Int64.Parse(ck);
long n= 0;
string pattern = "(?<=data-screen-name=\").*(?=data-name)";
while (n <= check)
{
WatiN.Core.Settings.WaitUntilExistsTimeOut = 1;
var focusme = ie.Div(Find.ByClass("stream-loading"));
var element = focusme.NativeElement as IEElement;
element.AsHtmlElement.scrollIntoView();
string dm = ie.Body.Parent.OuterHtml;
MatchCollection matches1 = Regex.Matches(dm, pattern);
n = matches1.Count;
label4.Text = n.ToString();
}
string dom = ie.Body.Parent.OuterHtml;
MatchCollection matches = Regex.Matches(dom, pattern);
foreach (Match match in matches)
{
string usr0 = match.ToString();
int i = usr0.IndexOf("\"");
string usr = usr0.Substring(0, i - 1);
wr.WriteLine(usr);
}
label4.Text = label4.Text + " done";
wr.Close();
}
This is the source, to get the twitter followers into a file. It's just a random example, but while performing this action, my program is not responding. I guess I have to create a new process for this action, but don't know exactly how to proceed.
EDIT: I am using this in the button1_Click, so basicly in the Form1 Class.