
OpenTK and WCF seemingly interfere with another
Posted Tuesday, 16 March, 2010 - 17:49 by Hecate inOpenTK is kind of vast and i am relatively new to it. I hope by asking here i can sort things out without having to search through the entire documentation right from the start. All programs are written in C#.
My brother is creating a game with networking via the windows communication foundation. I was programming a small application for very basic visual output, debugging is a lot easier then ( so far in the game there is only some physics like planet orbits, modular spaceships etc - no graphics yet ). It quickly resulted in an odd bug though:
After implementing his networking DLL and running a first test about blitting network chat messages to the screen, the messages did not arrive.
After debugging we noticed the messages do not appear in the list unless i move/rezize the window or rightclick the titlemenu. Once moving the window, even 30 seconds old messages appear just fine, they have to be stuck somewhere. Our first guess is both programs use windows internal event queues and the WCF events only get processed if certain window events are occuring. There is no interaction between my classes and his despite me instantiating his main networking class, telling it to connect and reading messages. It works fine on other PCs within the standard System.Console despite Console.Readline() blocking so you cannot see messages until you enter the next chatline. The messages always appear in time within the list though ( debugged it )!
Maybe someone knows why this is happening and in the best case szenario even a fix.
Notes:
Windows XP professional 32bit
MSVS 2008 professional
In my view unimportant info, but i'll attach it just in case:
2 nvidia 6600GT in SLI
Toledo AMD Athlon X2 64 4800+
relatively old graphics driver ( had MULTIPLE and VERY BAD experiences with newer nvidia drivers - never change a running system :P also to me there is no apparant reason this should affect a network class... )
Thanks in advance! If there is any additional information required, i will add it asap.


Comments
Re: OpenTK and WCF seemingly interfere with another
Interesting. I believe this issue has the same cause as #1526: Using XmlSerializer with OpenTK ends up in MDA ContextSwitchDeadlock in exactly 60 seconds but I do not know what that cause is, yet.
Two questions first:
[STAThread]?It would help a lot if you could isolate the issue in a simple test case.
My theory so far is that the message pump in OpenTK somehow fails to handle calls from other apartments, when running in a single-threaded apartment. When you right-click or move the window, Windows run a temporary, modal message pump that processes all those calls that have been piling up. Unfortunately, I am very familiar with COM-interop subtleties, so I don't know how to fix this issue off-hand. This is where the test case comes in: once the issue can be reproduced reliably, it's only a matter of time before the correct solution is found.
As a workaround (and confirmation of the above theory), you can try decorating your main method with [MTAThread]. Does the issue still occur then?
Re: OpenTK and WCF seemingly interfere with another
Sorry for the late answer, i had to think whether there was a better way of giving an example.
The [MTAThread] attribute didnt have any effect on the problem. I am using GameWindow, yes. The best test case i came up with was the following: I loaded QuickStart, converted it to .Net 3.5 ( the networking needs that, whatever ) and added the DLL references for the network-class. After instantiating it in the Game class and calling connect() in the OnLoad method i debugged and got the same error. If i set a breakpoint in the render method i only see the server's welcome message after i moved/rezized the window or rightclicked the title bar ( running for a few seconds, then looking at the messages, moving the window once then looking again ).
Changing the Main from [STAThread] to [MTAThread] didnt have any effect here either.
If you really want i can probably send you a .exe server file ( or the part of the code that does the networking, but i dont know how long that is ) and the necessary DLLs but i doubt that will do any good.