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 9251835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:48:00+00:00 2026-06-18T10:48:00+00:00

I can see from my debug messages that e.Result equals to Success all the

  • 0

I can see from my debug messages that e.Result equals to “Success” all the way through the DoWorker method, but at the beginning of the RunWorkerCompleted method e.Result returns nothing at all.

This is the __construct for the WinForm

public LicenseValidator()
{
    // Initialize the UI
    InitializeComponent();

    // Start the background worker
    BackgroundWorker worker = new BackgroundWorker();
    worker.DoWork += new DoWorkEventHandler(worker_DoWork);
    worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
    worker.RunWorkerAsync();

    // Tell debug log that the UI thread is still processing
    Debug.WriteLine("UI thread running");  
}

And here is my worker_DoWork method

public async void worker_DoWork(object sender, DoWorkEventArgs e)
{
    // Tell debug log that the worker thread is now running
    Debug.WriteLine("Worker thread running");

    // Define variables
    String HWID = Security.FingerPrint.Value();
    String APIPath = "http://xxxxxxxxx.net/api.php";
    String Serial;
    HttpClient client = new HttpClient();
    HttpResponseMessage response;
    String responseString;

    // Check for license in AppData
    try{
        // Get license path
        String licensePath = Environment.GetEnvironmentVariable("APPDATA") + @"\UniLeech\License.txt";
        // License exists, validate it
        if (File.Exists(licensePath))
        {
            Serial = File.ReadAllText(licensePath);
            Debug.WriteLine(Serial);
            response = await client.GetAsync(APIPath + "?hwid=" + HWID + "&serial=" + Serial);
            responseString = await response.Content.ReadAsStringAsync();
            Debug.WriteLine(responseString);
            dynamic jObj = JsonConvert.DeserializeObject(responseString);
            if (jObj.success == "true")
            {
                Debug.WriteLine("License validation was successful");
                e.Result = "Success";
            }
            else
            {
                e.Result = jObj.error;
            }
            Debug.WriteLine(e.Result);
        }
        // License does not exist, prompt for one
        else
        {
            Debug.WriteLine("License file not found");
            e.Result = "Unregistered";
        }
    }

Finally my worker_RunWorkerCompleted method

public void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
    Debug.WriteLine("Worker completed");
    String result = e.Result as String;
    if ((e.Error == null))
    {
        Debug.WriteLine("No errors");
        Debug.WriteLine("Result = " + result);
        if (e.Cancelled)
        {
            Debug.WriteLine("Worker cancelled");
        }
        switch ((String)e.Result.ToString())
        {
            case "Success":
                this.Hide();
                this.ShowInTaskbar = false;
                Main mainForm = new Main();
                mainForm.Show();
                break;

            case "Banned":
                popupError("ERROR: License revoked!",
                           "Your license has been revoked, contact Time Sheep for more information. You can purchase a new one by visiting the ordinary order link."
                          );
                break;

            case "Invalid":
                popupError("ERROR: Invalid serial/HWID",
                           "Either your serial number or hardware identifier was invalid. If you purchased UniLeech, please contact Time Sheep with proof of purchase."
                          );
                break;

            case "Unregistered":
                this.Hide();
                this.ShowInTaskbar = false;
                Register registerForm = new Register();
                registerForm.Show();
                break;

            default:
                MessageBox.Show((string)e.Result, "ERROR");
                break;
        }
    }
}

On execution the following debug messages appear (Case: I have the file and e.Result should be “Success”):

UI thread running
Worker thread running
0123-1234-1234 (The value of Serial)
Worker completed
No errors
{"success": "true","action": "validate","error": "None"} (Returned from web API)
License validation was successful
Success
RunWorkerCompleted finished

I suspect the issue is caused by the DoWork method being asynchronous, but I don’t know how to use HttpClient synchronously.

  • 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-06-18T10:48:01+00:00Added an answer on June 18, 2026 at 10:48 am

    You can’t have an async DoWork. BackgroundWorker assumes that when DoWork returns, it is completed.

    You don’t need BackgroundWorker at all. Just use Task.Run instead.

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

Sidebar

Related Questions

I have a setup a SQL Server instance that I can see from all
I am populating combo box from database. In debug i can see that the
As you can see from the documentation the way to start an Activity to
I'm using code from other c# app and I can see that in WP7
As you can see from the Client class, if the while breaks then the
I have some really funky code. As you can see from the code below
I have a web page where users can see data from MongoDB on a
From what I can see ui:dialog isnt a standard psuedo css element, so I
Hi below link from Vaadin you can see how to set checkboxes on tabletree,
How can I remove the animation from this jQuery modal window? You can see

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.