Threading Problem

  • Thread starter Thread starter Anshul
  • Start date Start date
A

Anshul

I have a typical scenario to work with and seeking help for the same.
The scenario is.

1) I have to write some code in Managed C++ and C# code.
2) Managed C++ will interact with Native windows service.

Detailed Information
C++ Dll
When the native windows service start, it calls its own callback Init (
) method in our C++ dll (coz these methods are exported from this dll).


Further, there is another exported method Query( ) is there, which
receives a query from windows Service and passes it for resolution in
C# dll.

C#Dll

This has two functionality : 1) Continuous Polling 2) Resolve queries
received from C++dll then after resolution passed to C++ dll which will
further pass it to Service.

Problem

I want to implement continous polling using thread more specifically
using TimerDelegate but no sucess. Although where should i spawn this
delegate in C++ or in C# dll.
 
Anshul,

The real problem is that you want to use continuous polling. In most
cases, it is better to use an event notification than to poll. You are just
wasting resources by polling.

It sounds like the C# dll will be hosted outside of the service (hence
the need for the polling, perhaps)? If this is the case, why not use
something like MSMQ to send messages between the two. That way, you don't
have to have some process cycling in a tight loop wasting processor time
just waiting for a message.

Hope this helps.
 
Hi,
Thanks for your reply.
I agree we could have implemented MSMQ however, regarding continuous
polling. Is there any way to have the control on thread.
Like:
Init()
{
Initiate the thread .....
} // When it comes here thread will be terminated

Is there any way through which the scope should remain and stop only
when native service unloads the dll.

Thanks
Anshul
Anshul,

The real problem is that you want to use continuous polling. In most
cases, it is better to use an event notification than to poll. You are just
wasting resources by polling.

It sounds like the C# dll will be hosted outside of the service (hence
the need for the polling, perhaps)? If this is the case, why not use
something like MSMQ to send messages between the two. That way, you don't
have to have some process cycling in a tight loop wasting processor time
just waiting for a message.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Anshul said:
I have a typical scenario to work with and seeking help for the same.
The scenario is.

1) I have to write some code in Managed C++ and C# code.
2) Managed C++ will interact with Native windows service.

Detailed Information
C++ Dll
When the native windows service start, it calls its own callback Init (
) method in our C++ dll (coz these methods are exported from this dll).


Further, there is another exported method Query( ) is there, which
receives a query from windows Service and passes it for resolution in
C# dll.

C#Dll

This has two functionality : 1) Continuous Polling 2) Resolve queries
received from C++dll then after resolution passed to C++ dll which will
further pass it to Service.

Problem

I want to implement continous polling using thread more specifically
using TimerDelegate but no sucess. Although where should i spawn this
delegate in C++ or in C# dll.
 
Back
Top