Triggering an Event that runs a program

We have a program running on an old UNIX box, written in Tickle, that FTPs files to a NT directory. Another program (VB) picks up the files, converts their format, moves them to another directory,etc...

Rather than have a service that runs every few minutes,  I would like to have the VB program waiting, idly, for a message from the sending program, who will then do the converts, etc..

The data is ultimately stored in a SQL_Database. The originating program could (maybe) write to a field in the SQL database that would trigger the event. The VB program could be coded and set up on NT to wait for a specific instruction from the Tickle program. Of course it will have to cross platforms from old UNIX to NT.

Any help is appreciated.

Who is Participating?

Improve company productivity with a Business Account.Sign Up

TimCotteeConnect With a Mentor Head of Software ServicesCommented:
hakre, you are new to this site so may not be aware of the guidelines. Please re-read these at the bottom of this page. Your "answer" which does not 100% solve this problem should have been posted as a comment as it now places this question in the "locked" section which will not allow it the attention it deserves. If you continue to post answers inappropriately your account may be referred to customer services for possibly penalty.

johnstde: I would suggest that you reject this proposed answer at this time to allow more experts the opportunity to comment. If you feel that hakre in the end has offered the best solution you may choose the accept comment as answer button to award him/her the points at any time after you have rejected this proposed answer.

Anyway hakre is probably on the right lines. Basically I would use the file system to handle this with a few api calls. Add in a touch of an NT service (NTSRV.OCX) get it here:

You should also use code such as this:

Private Const FILE_NOTIFY_CHANGE_ALL = &H4 Or &H2 Or &H1 Or &H8 Or &H10 Or &H100
Private Declare Function FindFirstChangeNotification Lib "kernel32" Alias "FindFirstChangeNotificationA" (ByVal lpPathName As String, ByVal bWatchSubtree As Long, ByVal dwNotifyFilter As Long) As Long
Private Declare Function FindCloseChangeNotification Lib "kernel32" (ByVal hChangeHandle As Long) As Long
Private Declare Function FindNextChangeNotification Lib "kernel32" (ByVal hChangeHandle As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function ResetEvent Lib "kernel32" (ByVal hEvent As Long) As Long
Private Sub Form_Load()
    'KPD-Team 2000
    Dim Ret As Long
    'Set the notification hook
    Ret = FindFirstChangeNotification("C:\", &HFFFFFFFF, FILE_NOTIFY_CHANGE_ALL)
    'Wait until the event is triggered
    WaitForSingleObject Ret, &HFFFFFFFF
    MsgBox "Event Triggered for the first time"
    'Reactivate our hook
    FindNextChangeNotification Ret
    'Wait until the event is triggered
    WaitForSingleObject Ret, &HFFFFFFFF
    MsgBox "Event Triggered for the second time"
    'Remove our hook
    FindCloseChangeNotification Ret
End Sub

To watch a specified folder (your ftp target folder) for new files being added. You can then run your conversion and output code and VB will then sit idle as a service until the next notification.
a) Use your file system
b) Use a Win32 Message / DDE

a) Just let the Tickle program create a file. The VB app will watch for this file in a loop. If it's created, VB will start processing. After doing all tasks, it will delete the file and the tickle program then knows, it can continue to work.

b) Let the tickle program, when ported to win32, send a message to your vb app which, in a subclassed routine, can pickup the message and start a working task. You could use DDE for this either.
johnstdeAuthor Commented:
Following above suggestion, I am rejecting the answer for now so I can spend some time looking at the options offered. Good ideas guys! Thanks for the link and details Tim.

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

I've worked with something like this in the past, and both Harke and TimCottee have the right idea.  One possible option/enhancement would be to have another 'listener' process sit in front of your main VB program (the one that 'picks up the files, converts their format, moves them to another directory,etc...').

This helps mainly if your main VB app is rather large and you don't want to have it constantly residing in memory.  Your 'listener' would instantiate the main program any time it received data or saw that the file was out there, and pass the data along.

Good luck

Richie_SimonettiIT OperationsCommented:
TimCotteeHead of Software ServicesCommented:
True kcleary but of course this could be the service process and you could either use an activex dll/exe or just shell out to a standard exe for the conversion process when necessary.
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.

All Courses

From novice to tech pro — start learning today.