Should I write a service?

  • Thread starter Thread starter TClancey
  • Start date Start date
T

TClancey

Hi all. I hope someone can give me a few pointers on 'best practice' for an
app I'm about to start.

I'm writing a small and simple label design application, users will define
text fields on the label in a GUI, some data may come from a database.

The application will be able to connect to any standard database in time,
but for the time being it's access.

I will need to 'bolt' this application into many other applications as time
goes by, these applications will all require label printing functionality,
but I don't want to include the designer code everytime, so I'll just add
the EXE and DLL's required to the install set.

The problem starts when the user actually wants to print a label. I don't
want the designer to load, so I need something sitting in the background
that will pick up the print instructions.

I'm thinking that I need a seperate EXE that will poll a folder location for
print requests, or create a service that will do the polling.

Where my knowledge ends is passing data to an EXE or a Service, not
something I have had to do before.

Can anyone share any experiences of this kind of thing?

Cheers,
Tull.
 
TClancey said:
Hi all. I hope someone can give me a few pointers on 'best practice' for
an app I'm about to start.

I'm writing a small and simple label design application, users will define
text fields on the label in a GUI, some data may come from a database.

The application will be able to connect to any standard database in time,
but for the time being it's access.

I will need to 'bolt' this application into many other applications as
time goes by, these applications will all require label printing
functionality, but I don't want to include the designer code everytime, so
I'll just add the EXE and DLL's required to the install set.

The problem starts when the user actually wants to print a label. I don't
want the designer to load, so I need something sitting in the background
that will pick up the print instructions.

I'm thinking that I need a seperate EXE that will poll a folder location
for print requests, or create a service that will do the polling.

Where my knowledge ends is passing data to an EXE or a Service, not
something I have had to do before.

Can anyone share any experiences of this kind of thing?

Cheers,
Tull.

To pass data to an exe is as simply as "shelling out" and executing the
command. For something like a service, though, is probably a bit harder.
Something that can be done is have a configuration file somewhere on the
local machine, and have the service read this configuration file (XML good
choice, IMO), and go from there. <shrug> just an idea :)

HTH,
Mythran
 
Yeah, this is kind of what I'm thinking. I also think a service may be a
little over the top for this app, it doesn't have to be running all the
time.

Cheers,
Tull.
 
Tull,
As Mythran suggests having the UI tell the service what to do can be tricky.

In addition to polling a folder location, you can use .NET Remoting (or the
newer WCF (Windows Communication Foundation)) to have the UI tell the
service to print a label. I would consider .NET Remoting over polling a
folder

In a corporation I would consider using MSMQ (either the System.Messaging
namespace or even the newer WCF over MSMQ) to allow multiple machines to
queue requests for labels to print. MSMQ is especially useful if you have
multiple machines requesting labels, but only one machine/printer printing
said labels.

NOTE: WCF is part of .NET 3.0 due out when Vista ships

..NET 2.0 includes an IpcChannel that allows one to limit .NET remoting to a
single machine.
 
Oh! I should add, Do you really need a separate EXE (service or otherwise)
to print a label, I would consider simply including that logic directly in
the same assembly that does the label UI.
 
Thanks for the info.

I had thought of Writing the whole package and calling the EXE differently
for design and print mode, but it's likely that the designer will be used
infrequently. I don't want the designer to be doing too much, like polling
in the background, so I think two apps is the way to go.

Again, thanks.
Tull.
 
Tull,
Designer aside.

What I am asking is the why does the act of printing need to defer to
another application.

If Application1 says "print it", why doesn't Application1 simply print it,
why have Application1 queue the request to print it so that Application2
needs to print it.
 
If the designer app were the only printing app then this is how I would do
it.

The designer is a basic attempt to add an exe to any project that I may
write, with the designer the users can create their own label formats.
'Mostly' the print requests will come from other applciations.that this exe
has been bundled with.

I've toyed with the idea of calling the Design app with data to print,
therefore avoiding the design environment, but it is also possible that the
designer may not be present and simple label printing from the host app is
all that is required.

With this complexity in mind I have decided to go with a 'print engine' that
can be called as and when required.

Of course, if you think I'm completely barking, please let me know, I'm more
than happy to try things before settling.

Cheers,
Tull.
 
Back
Top