I have the following code in a WinForms application with one button and one label:
using System; using System.IO; using System.Threading.Tasks; using System.
Because it's on a different thread and cross-thread calls aren't allowed.
You will need to pass on the "context" to the thread you are starting. See an example here: http://reedcopsey.com/2009/11/17/synchronizing-net-4-tasks-with-the-ui-thread/