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 += new

System.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!

 
Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: