PHP subscribe to C# dll events

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vanderlooj
Forum Newbie
Posts: 3
Joined: Tue Oct 12, 2010 6:26 am

PHP subscribe to C# dll events

Post by vanderlooj »

Hi there,

I have a PHP script that loads a C# dll file. This is working fine as I can call methods and access properties of the C# class.

For example:

Code: Select all


$obj = new COM("TestProject.DoesStuff");
$result = $obj->ReturnQWERTY();

But I am trying to subscribe to events in a C# class. I have done some research and googling, but I can't seem to find a solution for it.

I want the C# code to somehow execute a PHP function when an event is raised or executed in the C# class.
I can't seem to get my head around it. How can I accomplish this? Maybe pass some sort of callback function as a parameter to the class or something like that?

Any help or ideas would be greatly appreciated.

Thanks,
Cheers
ouchiko
Forum Commoner
Posts: 35
Joined: Sun Oct 09, 2011 6:54 pm
Location: London

Re: PHP subscribe to C# dll events

Post by ouchiko »

I have no idea what you are doing exactly but PHP isn't generally "event" driven. It's a one by one process such that:

$obj -> doSomething() will process and you will not be able to run $obj -> doAnotherProcess(); until the previous one is completed.

Having said that .. *if* the C# object is running a process but the initial call finishes but a subsequent event will occur then you could think of somethign like:


while ( !$obj -> isFinished )
{

So something else
sleep(1);
}

But the above is fairly rubbish - PHP doesn't thread so you'll cripple the processor whilst it waits. You could use pc_ntl fork but I think you're going down roads you don't want.

I'd be interested in more info on what you're doing - both languages are favourites of mine.
Post Reply