passing a variable to a method with a system.object parameter in c# -


my application simple. use timer executes method every 15 seconds.

i have application set have call timer open method creates string, calls logic method.

what want create string in timer method, pass string directly logic method. possible pass variable method system.object parameter inside of it?

//this piece of code in timer method (methoda) calls methodb  thistimer = new system.threading.timer(new timercallback(methodb));          private void methodb(object sender)         {         string thestring= "mystring";         methodc(thestring);         }   private void methodc(string thestring)         {         } 

what want is

//this code jumps directly methoda methodc string thestring= "mystring"; thistimer = new system.threading.timer(new timercallback(methodc(system.object,thestring)));       private void methodc(object sender, string thestring)             {             } 

use lambda close on variable(s) want use when providing callback timer:

string thestring= "mystring"; thistimer = new system.threading.timer(sender => methodc(thestring)); 

private void methodc(string thestring) { } 

Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -