Q:

How to pass a value to a anonym method in Task.Factory

I'm using a construct like that:
string myurl = "http://google.de";
Task.Factory.StartNew(() =>
{
   MessageBox.Show(url);
});

How to pass myurl to the anonym function?

A:

Just use it directly:
string myurl = "http://google.de";
Task.Factory.StartNew(() =>
{
   MessageBox.Show(myurl);
});

This is called a "closure".
If you don't want to do that then you can pass the url in as another parameter to StartNew:
string myurl = "http://google.de";
Task.Factory.StartNew(url =>
{
   MessageBox.Show((string)url);
}, myurl);

This second version is a tad more code, it limits you to only one parameter (so if you have several you need to either use a closure or put all of your parameters into some container object) and also types the parameter to object, thus forcing you to cast it to what it really is in the method body.  The advantage, on the other hand, is that there is a small overhead associated with closing over variables that you can potentially avoid using this method.  Note that in most situations this isn't going to be an important performance issue, so you should go with what is most convenient unless you have a reason to do otherwise.

