Passing Parameter Method into a Thread, Help!
-
public delegate void updatevalores(int total); public partial class FormConexiones : Form { private int procesosactuales = 0; public FormConexiones() { InitializeComponent(); } private void FormConexiones_Load(object sender, EventArgs e) { procesos proces = new procesos(); Thread pid = new Thread(new ThreadStart(proces.iniciar(new updatevalores(actualizarv)))); pid.Start(); } public void actualizarv(int total) { procesosactuales = total; } }
Another Class:class procesos { { struct sproceso { public int id; public string NombreProceso; public string DirProceso; public string FileProceso; public DateTime tiempoinicio; } ArrayList listaprocesos = new ArrayList(); bool existeproces = false; bool coincide = false; Timer nuevotiempo = new Timer(); public void iniciar(updatevalores procesoact) { nuevotiempo.Elapsed += new ElapsedEventHandler(TiempoEjecutar); nuevotiempo.Interval = 5000; nuevotiempo.Enabled = true; } }
The Line Thread pid = new Thread(new ThreadStart(proces.iniciar(new updatevalores(actualizarv)))); has give me an error. How i can pass values to proces.iniciar method?????????? Thanks -
public delegate void updatevalores(int total); public partial class FormConexiones : Form { private int procesosactuales = 0; public FormConexiones() { InitializeComponent(); } private void FormConexiones_Load(object sender, EventArgs e) { procesos proces = new procesos(); Thread pid = new Thread(new ThreadStart(proces.iniciar(new updatevalores(actualizarv)))); pid.Start(); } public void actualizarv(int total) { procesosactuales = total; } }
Another Class:class procesos { { struct sproceso { public int id; public string NombreProceso; public string DirProceso; public string FileProceso; public DateTime tiempoinicio; } ArrayList listaprocesos = new ArrayList(); bool existeproces = false; bool coincide = false; Timer nuevotiempo = new Timer(); public void iniciar(updatevalores procesoact) { nuevotiempo.Elapsed += new ElapsedEventHandler(TiempoEjecutar); nuevotiempo.Interval = 5000; nuevotiempo.Enabled = true; } }
The Line Thread pid = new Thread(new ThreadStart(proces.iniciar(new updatevalores(actualizarv)))); has give me an error. How i can pass values to proces.iniciar method?????????? Thanks -
public delegate void updatevalores(int total); public partial class FormConexiones : Form { private int procesosactuales = 0; public FormConexiones() { InitializeComponent(); } private void FormConexiones_Load(object sender, EventArgs e) { procesos proces = new procesos(); Thread pid = new Thread(new ParameterizedThreadStart(proces.iniciar)); pid.Start(new updatevalores(actualizarv)); } public void actualizarv(int total) { procesosactuales = total; } }
Give me an error withParameterizedThreadStart(proces.iniciar)
The error is: none overload correspond 'iniciar' match with 'System.Threading.ParameterizedThreadStart' delegate what the :mad: -
public delegate void updatevalores(int total); public partial class FormConexiones : Form { private int procesosactuales = 0; public FormConexiones() { InitializeComponent(); } private void FormConexiones_Load(object sender, EventArgs e) { procesos proces = new procesos(); Thread pid = new Thread(new ParameterizedThreadStart(proces.iniciar)); pid.Start(new updatevalores(actualizarv)); } public void actualizarv(int total) { procesosactuales = total; } }
Give me an error withParameterizedThreadStart(proces.iniciar)
The error is: none overload correspond 'iniciar' match with 'System.Threading.ParameterizedThreadStart' delegate what the :mad:damn i forget to read:
This is simple, but only accepts a single parameter and isn't type-safe (just like the options when using thread pool threads)
:-> -
damn i forget to read:
This is simple, but only accepts a single parameter and isn't type-safe (just like the options when using thread pool threads)
:-> -
Yep Works Fine:
procesos proces = new procesos(); ThreadStart inipro = delegate { proces.iniciar(new updatevalores(actualizarv)); }; new Thread(inipro).Start();
Ok, so much battle with Thread and asyncronic querys... time to rest :zzz: thanks for all :D -
Yep Works Fine:
procesos proces = new procesos(); ThreadStart inipro = delegate { proces.iniciar(new updatevalores(actualizarv)); }; new Thread(inipro).Start();
Ok, so much battle with Thread and asyncronic querys... time to rest :zzz: thanks for all :D