Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7537407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:50:37+00:00 2026-05-30T06:50:37+00:00

I am new to c# task, what I want to do is convert downloadThread

  • 0

I am new to c# task, what I want to do is convert

downloadThread = new Thread(DownLoadFile); 
downloadThread.Start();

to task like

var t = Task.Factory.StartNew(DownLoadFile);

I also know to use CancellationTokenSource to cancel the task. However, the examples I saw are all long loop running threads, such as for, foreach, while, and they check IsCancellationRequested to cancel the task in the loop.

if (ct.IsCancellationRequested)
{
    break;
}

But my long running task is to download a file with FTP. The GetFile method is from a third party dll library.

ftp.GetFile(ftpPath, dest, false);

Since my long running task is not in any loops, how can I check for and then cancel it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T06:50:39+00:00Added an answer on May 30, 2026 at 6:50 am

    If the third party API doesn’t support cancellation, there’s no clean way of doing it. You can abort the thread, but I’d strongly advise that you only do that if you’re killing the whole process (or at least the AppDomain).

    If at all possible, find an equivalent API which does support cancellation, or just abandon the request and let it take its course, just ignoring the result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am relatively new to multi-threading and want to execute a background task using
I am new to async task . I need to use httppost in my
I have a task that returns a value, but I want to convert that
I want to use TASK for running parallel activities.This task returns a value.How do
What I want basically to acomplish is to schedule on a task_group new work
The latest Google App Engine release supports a new Task Queue API in Python.
I am just in a process of starting a new task, wherein in i
C# has a cool new feature public Task<string> async f() { string r =
I'am new to NHibernate and i have a task to enhance a project with
I am new this sharepoint development and i have task in hand to do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.