Question: I'm trying to do something that I thought would be easy but can't figure out how to write to a label inside my stating function.

```
public static void StartProcessing(object data)
{

   lblError.Text = "Blah Blah"
}

```

I get the error "An object reference is required for the non-static field, method, or property..."

So I tried creating a new instance of the label and adding it to a new instance of a control (Panel) but the lblError isn't getting displayed

```
  public static void StartProcessing(object data)
    {
       Panel Panel1 = new Panel();
       Label lblError= new Label();
       Panel1.Controls.Add(lblError);

       lblError.Visible = true;
       lblError.Text = "Blah Blah";

    }

```

there must be an easy way to do this? Which i've overlooked..

The function is getting called as follows: If I change the above to not be static I get an error message on the second line below saying the same "An object reference is required for the non-static field, method, or property..." When this function isn't static?

```
public object LaunchNewProcess(object data)
{
ThreadPool.QueueUserWorkItem(
                new WaitCallback(ProcessStatuses.StartProcessing),
                new object[] {newProcess, allProcesses}
                );

```

Answer: 
Pass the label to your static function when you call it:

```
public static void StartProcessing(object data, Label lblError)
{

   lblError.Text = "Blah Blah"
}

```

Static functions don't have access to controls because the controls belong to the *instance* of the page (class).

**Static** means that all instances of a class share the same function or variable. So, an instance of a class has access to a static variable or function. However, since a static is not "aware" of any instances of the class, it cannot access the members of an instance. In fact, a static method or variable does not even require any instance of the class to exist, so how could it?

Removing the `static` key word from your function will also work, as others have mentioned, but I'm assuming you made it static for a reason.

*EDIT*
Alright, this is more complex.

So, you have some class that launches a bunch of threads, and you want it to display to the user if something went wrong? Well, your current approach is flawed because you cannot access controls of a page without the instance of the page. Also, I am not sure how this approach would fit within the page lifecycle.

Your best approach (sorry for lack of code, it's going to depend a lot on your implementation) could be something like this:

```
//do this before you start spawning threads
List<bool> successes = new List<bool>();

ThreadPool.QueueUserWorkItem(
            new WaitCallback(ProcessStatuses.StartProcessing),
            new object[] {newProcess, allProcesses, successes}
            );

//you MUST wait for all your threads to complete before proceeding!
if(successes.Any(s => !s))
{
    //update your error label
}

public static void StartProcessing(object data, Label lblError)
{
    var dataArray = (object[3]) data;
    //if there is an error
    dataArray[2] = false;
}

```
What you want to do is actually quite difficult.

You want to create a page, start an asynchronous task, send the page to the user, and then update content on the page after the asynchronous job finishes.

The problem is that by the time the asynchronous task finishes the page has already been sent, and based on the way HTTP works once you've sent your response you're done; there's not more communicating with the client for you. You need to wait for the client to send another request if you want to update them.

This means that you need to have JavaScript code that is constantly polling the server basically asking, "Are you done yet, are you done yet, are you done yet?" until eventually the server says, "Yes, here's something to display on the page".

Fortunately, you don't need to start from scratch. [Here](http://code.msdn.microsoft.com/CSASPNETBackgroundWorker-dda8d7b6/view/SourceCode) you'll find an example by Microsoft that does all of this; you can modify it to suit your needs. It's also worth mentioning that in addition to being non-trivial to program, it also consumes a lot of resources to constantly poll the server, so be sure you really need to do this.

Option 2 is to just not start the other tasks in new threads, and execute the code serially before the page is ever returned to the user. They'll be staring at a blank screen for a while, but it'll be MUCH easier to program. The one downsize to keep an eye on here is on timeouts if the task is REALLY long running.