Saturday, March 24, 2012

Wait for COM-Events

Hi,
on the server side of my asp.net web-app, i need to instantiate a comcomponent and invoke some methods on it (e.g. Login()). After that ihave to wait for an Event fired by the com-component (e.g. wait for anUSER_LOGIN_SUCCESS). During that time i need to wait on the server(Page-File) and block the request.
I generated the Runtime Callable Wrapper and registered the Event onclass that encapsulates the component. The Event-Handler sets the boolean logonCompleted to true. The Blocking is implemented bythe following code:
while(!logonCompleted){
System.Threading.Thread.Sleep(1000);
}
Is there any other (better) solution for that problem. I think thiscode would cause some big performance and scalability issues becauseeach Page-instance is handled by the same Thread. Did anybody else havesome experiences with that problem?
Thank you for participating.
best regards,
larsI don't know of another method that will achieve what you are doing.
However I am pretty certain that each page instance is not handled by the same thread. I don't have a good reference book in front of me to quote from though. It doesn't make sense that each default.aspx page ( for example) is run by the same thread as that is an immediate contention issue. As default is probably the most hit page, forcing them all into the same thread would cause a big bottleneck. So I wouldn't worry about sleeping your page thread.

Oh yeah, my fault. Of course each page-request is handled by anotherthread. But one page-instance is handled by the same thread.
In MSDN i read something about the Server.SpinWait()-method, but a moreprecisely explaination (what is the difference to sleep) is missing.


This seems to be a good description.
http://groups.google.ca/group/microsoft.public.dotnet.framework.clr/browse_frm/thread/58a3351b6202c976/bf27d53864a322cb?hl=en&lr=&ie=UTF-8&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26q%3DThread.SpinWait%26btnG%3DSearch%26meta%3Dgroup%253Dmicrosoft.public.dotnet.*#bf27d53864a322cb

0 comments:

Post a Comment