static BackgroundWorker worker; static void Main(string[] args) { worker = new BackgroundWorker(); worker.DoWork += worker_DoWork; worker.RunWorkerAsync(); Console.ReadLine(); } static void worker_DoWork(object sender,DoWorkEventArgs e) { string strClientId = "2211"; Authenticate(ref strClientId); //whatever You want the background thread to do... } static void Authenticate(ref string strClientId) { Timer timer = new Timer(500); //Error in this line //Cannot use ref or out parameter 'strClientId' inside an anonymous method,lambda expression or query expression timer.Elapsed += (sender, e) => Authenticates_Timer(sender, e,Func<strclientid>); //timer.Elapsed += Authenticates_Timer(); timer.Start(); } static void Authenticates_Timer(object sender, ElapsedEventArgs e, ref string strClientId) { //want to use variable here strClientId = ""; }</strclientid>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)