Home
> Uncategorized > Writing a C# Application without a user interface
Writing a C# Application without a user interface
I was looking to write a C# program which had no particular need for a user interface. My first stop was to develop a windows service, however, this proved too difficult to debug, so I decided to re-implement it as a windows forms app, with the form removed.
This application needed to poll a connection, every 5 seconds, and run idefinitely.
public
System.Timers.Timer tmrPoll = new System.Timers.Timer();[STAThread]
static void Main(){
VoiceMailMain vmmInstance =
new VoiceMailMain();vmmInstance.tmrPoll.Enabled =
true;vmmInstance.tmrPoll.Interval = 5000;
vmmInstance.tmrPoll.Elapsed +=
newSystem.Timers.ElapsedEventHandler(vmmInstance.tmrPoll_Tick);
System.Threading.Thread.CurrentThread.Suspend();
}
public
void tmrPoll_Tick(object sender, System.Timers.ElapsedEventArgs e){ … and magic happens … }
Simple when you know how!
Categories: Uncategorized
Comments (0)
Trackbacks (0)
Leave a comment
Trackback