Console Stop/Pause/Resume Events

I have a Console Application that runs well under Windows, but now I want to compile it for Macintosh and Linux. The three app Events: Stop, Pause and Resume give a compile error ‘You cannot implement a nonexistent event’ i.e. these events are not applicable to Macintosh. I have tried #if targetWin32 then … and #Pragma Unused … but neither seem to work.

How can I keep this Event code for Windows but disable it for the other platforms? Will I need to delete the events before non-Windows compiles, or is there another technique I am missing?

[quote=162261:@David Cox]I have a Console Application that runs well under Windows, but now I want to compile it for Macintosh and Linux. The three app Events: Stop, Pause and Resume give a compile error ‘You cannot implement a nonexistent event’ i.e. these events are not applicable to Macintosh. I have tried #if targetWin32 then … and #Pragma Unused … but neither seem to work.

How can I keep this Event code for Windows but disable it for the other platforms? Will I need to delete the events before non-Windows compiles, or is there another technique I am missing?[/quote]

Conditional compilation should take care of that for code. But how are you implementing the events ? You cannot use them outside of the #if targetWin32 at all.

The only one I really use in Windows is the Stop Event — it updates a PostgreSQL database status field to say the Console application has been shut down. This code is not Windows-specific, in fact not much at all in the app is Windows-specific.

The error you report makes me think you may be trying to addhandler to the Stop event out of the Win32 conditional code.

I’ve worked it out! When I set the Application Super to ‘ServiceApplication’ I can add the Events: Pause, Resume and Stop, but when I change the Super back to ‘ConsoleApplication’ these Events are no longer available.

It seems I can compile a Mac and Linux Console app even when its Super is set to ‘ServiceApplication’ — I had assumed it could not and had changed it to ‘ConsoleApplication’.

Correction — a console application with Super ‘ServiceApplication’ compiles on the Mac with those extra Events present, but when run in the debugger it quits without running.

Are you daemonizing the app?

No, I am not daemonizing the app. I’ve set its Super back to ‘ConsoleApplication’ and am testing it for Mac now, after removing the semi-superfluous ServiceApplication app Events.