Z
Zlajoni
Hi, I am a bigginer at c# so I have problems accesing my timer from
another module. I supose that this is possible to do, I just don't
know how?
What I have is an Form which has a timer, somthing like this (Main
Module):
namespace RasTrailTest
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button btHangup;
private System.Windows.Forms.ListBox liBStatus;
private System.Threading.Timer FtpErrorTimer;
public Form1()
{
InitializeComponent();
if (FtpErrorTimer == null)
// first time through, create the timer
FtpErrorTimer = new System.Threading.Timer(new TimerCallback
onFtpErrorElapsed), null,
System.Threading.Timeout.Infinite,System.Threading.Timeout.Infinite);
}
public void StopErrorTimer()
{
FtpErrorTimer.Change(
System.Threading.Timeout.Infinite,System.Threading.Timeout.Infinite);
}
public void StartErrorTimer(int interval)
{
FtpErrorTimer.Change(interval, 0);
}
void onFtpErrorElapsed(object state)
{
StopErrorTimer();
//rest of the code here
}
}
}
That is a shortend version of my form module.
Here is the module which from I some how want to call
StartErrorTimer() and StopErrorTimer():
public class FtpClient
{
public FtpClient(string server, string username, string password)
{
this.server = server;
this.username = username;
this.password = password;
}
public void Download(string remFileName,string
locFileName,Boolean resume)
{
//SomeCode
//I WOULD LIKE TO CALL THE TIMER HERE!!!!!HOW TO DO THIS?
}
{
Is there anybody who can show me how this can be done? I have tried by
creating new Form1 object in my Ftp Module, but that would't help
because I would create a new Form on: Form1 frm = new Form1();
Best Regards
Zlajoni
another module. I supose that this is possible to do, I just don't
know how?
What I have is an Form which has a timer, somthing like this (Main
Module):
namespace RasTrailTest
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button btHangup;
private System.Windows.Forms.ListBox liBStatus;
private System.Threading.Timer FtpErrorTimer;
public Form1()
{
InitializeComponent();
if (FtpErrorTimer == null)
// first time through, create the timer
FtpErrorTimer = new System.Threading.Timer(new TimerCallback
onFtpErrorElapsed), null,
System.Threading.Timeout.Infinite,System.Threading.Timeout.Infinite);
}
public void StopErrorTimer()
{
FtpErrorTimer.Change(
System.Threading.Timeout.Infinite,System.Threading.Timeout.Infinite);
}
public void StartErrorTimer(int interval)
{
FtpErrorTimer.Change(interval, 0);
}
void onFtpErrorElapsed(object state)
{
StopErrorTimer();
//rest of the code here
}
}
}
That is a shortend version of my form module.
Here is the module which from I some how want to call
StartErrorTimer() and StopErrorTimer():
public class FtpClient
{
public FtpClient(string server, string username, string password)
{
this.server = server;
this.username = username;
this.password = password;
}
public void Download(string remFileName,string
locFileName,Boolean resume)
{
//SomeCode
//I WOULD LIKE TO CALL THE TIMER HERE!!!!!HOW TO DO THIS?
}
{
Is there anybody who can show me how this can be done? I have tried by
creating new Form1 object in my Ftp Module, but that would't help
because I would create a new Form on: Form1 frm = new Form1();
Best Regards
Zlajoni