Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abot 1.2.3 with multiple threads is not stopping with CancellationTokenSource #7

Closed
sjdirect opened this issue Feb 8, 2014 · 0 comments
Labels

Comments

@sjdirect
Copy link
Owner

sjdirect commented Feb 8, 2014

I am using the latest Abot 1.2.3 via NuGet.
Maybe I am doing something wrong but the following code does not stop the crawl process:

    CancellationTokenSource cts = new CancellationTokenSource();

    private void btnStart_Click(object sender, EventArgs e)
    {
        BackgroundWorker bgw = new BackgroundWorker();
        bgw.DoWork += bgw_DoWork;
        bgw.RunWorkerCompleted += bgw_RunWorkerCompleted;
        bgw.RunWorkerAsync();
    }

    void bgw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
    {
        //never reaches this point
    }

    void bgw_DoWork(object sender, DoWorkEventArgs e)
    {
        PoliteWebCrawler crawler = new PoliteWebCrawler();
        crawler.PageCrawlCompletedAsync += crawler_PageCrawlCompletedAsync;
        CrawlResult result = crawler.Crawl(new Uri("http://www.finanzen-forum.net"), cts);
    }

    void crawler_PageCrawlCompletedAsync(object sender, PageCrawlCompletedArgs e)
    {

    }

    private void btnStop_Click(object sender, EventArgs e)
    {
        cts.Cancel();
    }

The problem only occurs when you have set multiple threads (in my case 20 threads) and you have to let the crawler run a bit (15 seconds was enough to reproduce the problem).

If you are using 1 thread, it works.

I know that you have to wait a bit, depending on how much threads you have started but I have waited for over a minute for Abot to end all 20 threads. No success.

@sjdirect sjdirect added the bug label Feb 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant