Click here to Skip to main content
11,500,413 members (71,464 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# GUI Handling event
Hi currently I am writing a GUI which calls a C H.264 video decoder library. I want to stop the decoder as soon as it finishes decoding one frame and updating a buffer and then read this buffer from C# GUI and then display the same.

How can I achieve this? , not much information is present on event handling between C and C#. Can someone help me out with this, I desperately need a solution, deadlines approaching.

Posted 19-Jul-12 4:04am
ryanb31 at 19-Jul-12 10:14am
I would start by asking whoever developed the decoder library. You want to control how their code works so I would start with them.
mYashodhar at 19-Jul-12 10:27am
its my decoder and I have complete access to it.
ryanb31 at 19-Jul-12 10:30am
I'm confused then. This is all code you have written so I guess I do not understand exactly what you are asking for. Does your decoder raise an event after it processes each frame or have a property to indicate it stops after each frame? It's your code so I would assume you could do whatever you need. I think we need a more clear explanation of what you are asking.
mYashodhar at 19-Jul-12 13:02pm
currently it raises an event when ever a decoded frame is available, and as its my code to manipulate, I can change this methodology if necessary

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If you mean C, and not for example C++ with COM, events are not part of its methodology. Nor are interruptible threads or methods. I'd recommend that you expose the 'do one frame' function directly to the outside (i.e. so the C# library can call that), and manage the interruptible loop of calling that function and reading the result in the C# side (in a background thread, probably).
mYashodhar at 19-Jul-12 13:08pm
I cannot expose the 'do one frame' function directly as the code is tightly coupled and as the source for decoder could be an off-site streaming server, I do not have the liberty to decide on the incoming packets and hence cannot separate the single frame function as it would mean communication and parsing the data from the server through c#; which has already been implemented in the decoder C code
BobJanova at 19-Jul-12 13:15pm
Okay, so new plan: have your C function accept a pointer to a callback function (which you can hook to with a delegate in C#), that returns whether processing should abort and close the streams etc. That function (in C#) can simply return true or false depending on whether you want to cancel.
mYashodhar at 19-Jul-12 13:25pm
Nice! Ill try it out and let you know!.. thanks alot! I think this should work! :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 295
1 Maciej Los 295
2 DamithSL 210
3 Peter Leow 200
4 OriginalGriff 167
0 Sergey Alexandrovich Kryukov 345
1 Maciej Los 290
2 DamithSL 220
3 Peter Leow 181
4 OriginalGriff 167

Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 19 Jul 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100