Create service-application for windows XP


If using a service isn't a wise thing to do, than other solutions are welcome too. I need to build it from scratch anyway.

The following is what I want to accomplish:
A customer is visiting my trainingfacility. He is checking-in by using his magnet-card.
The magnetcardreader is attached to a serial-com port.

Here is the part the service comes in:
The service-application identified that data is send by the com-port.
The send data contains an identificationnumber of the customer.
The service will update a database to register that the customer is present. (if he scans a second time he will be checked-out).
Also the service will show a windows-popup containing the name and picture of the customer.
The popupscreen will disapear automatically after 3 seconds.

What would be a good way to implement this behaviour?
Can anybody give me some example or guidelines?

Stef MerlijnDeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

a service is a good idea and fits the needs.

now the needed imlementation is the trocky part: you don't know/have anything on how to do it?
1) do you have components for the serial communication part?
2) do you have the database part covered or are you able to cover it?
3) is the popup thing really needed? better make that configurable (imagine the case of 10-30 customers visiting at once (not a real life situation, but you never know)

it's been a while since I last worked with serial communication, but at that time (about 33-4 years ago) I used AsyncFree.
as database components, it really depends on the backend.

the implementation itself is pretty simple though:
- the service will start a listener thread that gets the data from the serial port. when data is available, it is put in a queue and a callback function of somekind is called that get the data from the queue (synchronization is needed here ;) )and makes out the data package in a readable format for the app. this is then put in the DB and the popup (which runs in its own thread)  is fired.

that should be it.
Stef MerlijnDeveloperAuthor Commented:
Thank you for your info.
I don't have any experience with using threads, listening to serialports nor callback (synchronisation) and queing of data. I can cover the databasepart, so we can skip that.
I don't have any component for the serial communication part, but will buy probably TMS ASync32.

So as you see a lot of help is needed here.
well then, we'll do it one step at a time:
1) get familiar with TMS ASync 32 (this should be fairly easy, so you can actually write a class that gets the desired data from the card reader)
2) for threads, you can look over the following examples/tutorials:
3) queueing data basically implies to use a queue class (TQueue, TObjectQueue for example: add "contnrs" to the uses clause to use them; use push/pop to add get items from the queue)
4) synchronizing access to a resource can be done in various ways: semaphores, critical sections, mutex, etc. I couldn't find a good tutorial on this for delphi, but the following is pretty good for a begginer:
 Probably the easiest way for a begginer is to use a thread-safe component. I couldn't find in a short period of time a good example for this.
Personally I prefer using critical sections to do the job. You have more control over things with this :)

uses SyncObjs;
global var cs:TCriticalSection = new TCriticalSection;// one per shared resource

      use the resource

the above pattern will make sure that no critical section will be left locked ;)

let me know when you bump into issues

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Stef MerlijnDeveloperAuthor Commented:
At the moment I can't do any testing as I have to wait for my own customer to give a GO to the project. So I don't have ASync32 nor a magnetreader.
The way you describe the way to implement it is not that easily form me to understand as I have no experience with this part of delphi-programming. So some additional help would be greatly appreciated when the project will start.
well, we answer questions here, solve problems, but we do not help in making projects. there are other sites  (services) for that were you can hire a coder to do part or all of the job.
we can give you pointers, examples and otherwise information that will help you do your job, but not do your job or part of it for you. it's not ethical.

the information I have given you in basic design and some examples/tutorials are more than enough to get your on the right tracks. but you have to do the rest yourself and come back when you have problems/issues implementing and we will help you gladly.

Stef MerlijnDeveloperAuthor Commented:
I understand that.
Thank you for your directions.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.