By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,206 Members | 1,417 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,206 IT Pros & Developers. It's quick & easy.

Threading Problem

P: n/a
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.

May 16 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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]
- mv*@spam.guard.caspershouse.com

"Anshul" <an************@gmail.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
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.

May 16 '06 #2

P: n/a
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

Nicholas Paldino [.NET/C# MVP] wrote:
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]
- mv*@spam.guard.caspershouse.com

"Anshul" <an************@gmail.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
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.


May 17 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.