January 6th, 2009, 01:28 PM
Help on this custom event 4 x app. interface
I have this application that is in C# and works with the financial markets.
It allows users to program any kind of studies, indicators or charts at wish but only if they have the app. Compile and run the code within itís own process. In other words Itís explicit DLLís are not accessible from outside world.
I have however managed to get it to write to and read from Global Variables that I can have access to the same GVís from outside too.
The app. Also has a custom event maker nad my thinking is to code all my applications outside, for example like making keyboard Macro commands that can be triggered through my GUI made outside to for each Macro place a simple flag in the Global Variables and then code events for the Global Variables that when their state changes to let the custom event within the other application know and then the application based on the code received to carry out the necessary steps.
I donít know if I explained myself clearly or not but what I need to know is :
1- If I could achieve the above utilizing the other applicationís custom event maker known as TriggerCustomEvent?
a. The snippet below show an example of how the custom event maker TriggerCustomEvent can be used with a timer.
2- Is my suggested approach the best way for getting inside the other app. As in the case of making a keyboard Macro or there are other ways that youíd suggest for achieving the same?
I sincerely thank you for your help, being a NewB in C# but desperate to get this doneÖ
Sample of the code to make an event for the timer:
/// Called on each bar update event (incoming tick)
protected override void OnBarUpdate()
if (CurrentBar == 0)
// Initiate our Timer object with an interval of 1000ms (1 second)
myTimer.Tick += new EventHandler(TimerEventProcessor);
myTimer.Interval = 1000;
// Timer's tick event handler. Called at every tick of 1000ms.
private void TimerEventProcessor(Object myObject, EventArgs myEventArgs)
/* Important to use the TriggerCustomEvent() to ensure that NinjaScript indexes and pointers are correctly set.
Do not process your code here. Process your code in the MyCustomHandler method. */
private void MyCustomHandler(object state)
// Informs us of when the event was triggered and of our Timer settings
Print("\tTime: " + DateTime.Now);
Print("\tTimer Interval: " + state.ToString() + "ms");
// Prints the L2 Ask Book we created. Cycles through the whole List and prints the contained objects.
Print("Ask Book: ");
for (int idx = 0; idx < askRows.Count; idx++)
Print("Ask Price=" + askRows[idx].Price + " Volume=" + askRows[idx].Volume);
// Prints the L2 Bid Book we created. Cycles through the whole List and prints the contained objects.
Print("Bid Book: ");
for (int idx = 0; idx < bidRows.Count; idx++)
Print("Bid Price=" + bidRows[idx].Price + " Volume=" + bidRows[idx].Volume);
// Important to clean up our resources
public override void Dispose()
// Make sure you include base.Dispose() whenever you override the Dispose() method
// Cleans up our Timer object
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.