This question is prob. extremely trivial but I can't seem to find out
what is going on. I've been doing some basic work with Multithreading
and Worker Threads and have determined I'd like to set up a minor
project that has ThreadingPools.
I can't seem to get it to compile whether I follow the example
tutorials or I don't. Of course the latter has a higher percentage of
failing :)
Anyways the line that fails is:
ThreadPool::Que ueUserWorkItem( gcnew
System::Threadi ng::WaitCallbac k(t->ThreadCallBack ),i);
The examples don't show anything being passed into the function but
it's a bit necessary for me to have each of the threads know what
numbers they are. So I'd really like to send in the number they are.
The function I'm sending them to is:
void dthread::Thread CallBack(Object ^ threadContext){
...
....
...
}
Now the errors I get all have to do with delegation of functions or
with pointers. I assumed that with this being a managed project I
didn't have to deal with most of that.
Errors:
Error 1 error C3867: 'dthread::Threa dCallBack': function call missing
argument list; use '&dthread::Thre adCallBack' to create a pointer to
member
Error 2 error C3350: 'System::Thread ing::WaitCallba ck' : a delegate
constructor expects 2 argument(s)
Before you go about telling me that I shouldn't be using -to point to
the function in the class allow me to tell you that my function is
*not* static. Furthermore I have instantiated the class before hand.
I"ve been following two tutorials from msdn, one does it, the other
doesn't.
Ie:
for (int i = 0; i........; i++){
MRE[i] = gcnew ManualResetEven t(false);
dthread^ t = gcnew dthread(this->clb_List->Items[a]->ToString(),
MRE[i]);
WTHREAD[i] = t;
System::UInt32^ m_i = gcnew UInt32(i);
ThreadPool::Que ueUserWorkItem( gcnew
System::Threadi ng::WaitCallbac k(t->ThreadCallBack ),i);
}
Now I can make one of them go away by removing the parameter or even
moving the parameter into the WaitCallback but I dont think thats
right. Can anyone point me into the right direction.
TIA.
G 1 1759
<gn*****@gmail. comwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
This question is prob. extremely trivial but I can't seem to find out
what is going on. I've been doing some basic work with Multithreading
and Worker Threads and have determined I'd like to set up a minor
project that has ThreadingPools.
I can't seem to get it to compile whether I follow the example
tutorials or I don't. Of course the latter has a higher percentage of
failing :)
Anyways the line that fails is:
ThreadPool::Que ueUserWorkItem( gcnew
System::Threadi ng::WaitCallbac k(t->ThreadCallBack ),i);
That's how C# would do it...
In C++/CLI you need
ThreadPool::Que ueUserWorkItem( gcnew System::Threadi ng::WaitCallbac k(t,
&dthread::Threa dCallBack),i);
>
The examples don't show anything being passed into the function but
it's a bit necessary for me to have each of the threads know what
numbers they are. So I'd really like to send in the number they are.
The function I'm sending them to is:
void dthread::Thread CallBack(Object ^ threadContext){
..
...
..
}
Now the errors I get all have to do with delegation of functions or
with pointers. I assumed that with this being a managed project I
didn't have to deal with most of that.
Errors:
Error 1 error C3867: 'dthread::Threa dCallBack': function call missing
argument list; use '&dthread::Thre adCallBack' to create a pointer to
member
Error 2 error C3350: 'System::Thread ing::WaitCallba ck' : a delegate
constructor expects 2 argument(s)
Before you go about telling me that I shouldn't be using -to point to
the function in the class allow me to tell you that my function is
*not* static. Furthermore I have instantiated the class before hand.
Doesn't matter. You can only refer to a member function by the class name,
not by an instance.
I"ve been following two tutorials from msdn, one does it, the other
doesn't.
Ie:
for (int i = 0; i........; i++){
MRE[i] = gcnew ManualResetEven t(false);
dthread^ t = gcnew dthread(this->clb_List->Items[a]->ToString(),
MRE[i]);
WTHREAD[i] = t;
System::UInt32^ m_i = gcnew UInt32(i);
ThreadPool::Que ueUserWorkItem( gcnew
System::Threadi ng::WaitCallbac k(t->ThreadCallBack ),i);
}
Now I can make one of them go away by removing the parameter or even
moving the parameter into the WaitCallback but I dont think thats
right. Can anyone point me into the right direction.
TIA.
G This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Duane Pressley |
last post by:
I'm looking for someone to help me make sense of the results I'm observing when using the ThreadPool class in a COM-Interop scenario. Here's the set up:
1.. A classic ASP page instantiates and calls MethodA on COM+ Class (C1).
2.. MethodA of COM+ class (C1) instantiates and calls MethodB of .NET class (N1). (Note: N1 has been registered using RegASM and is present in the GAC).
3.. MethodB of .NET class (N1) uses the...
|
by: Barrie |
last post by:
I'm having a quite complicate situation, and it doesn't want to
compile.
The situation is as follows:
I have three classes, let's call them A, B and C. They each have a .h
and a .cpp file.
All headers use the following construct to make sure the headers are
not included multiple times:
#ifndef _A_H_
#define _A_H_
class A {
|
by: Yan |
last post by:
Here is the code:
class A {};
void (A::*A) (); // Line 3
int main() {
A a; // Line 6
return 0;
}
|
by: etienne |
last post by:
Hello,
I'm trying to compile this C++ code with gcc 3.4.5 under Solaris/SPARC
(from a complete application, the file is : FullLinkedList.hh) but the
make fails (no problem when compiling under ubuntu/x86) :
(from line 330 to 481)
/*****************************************************************************
* ITERATOR SECTION - INNER CLASSES
|
by: dorkrawk |
last post by:
I am having an issue with some VC++ I am writing. I have a struct and
I'm trying to call a function from it from a function in another
object.
here is the struct....
struct JNI_Interface
{
JavaVM *jvm; /* denotes a Java VM */
JNIEnv *env; /* pointer to native method interface */
| |
by: Pucca |
last post by:
Hi I'm using vs2005. I am getting a bunch of compiler warnings after I made
some changes to my code that was compiling clean. I'm also getting memory
errors when I run my program and it's pinvoking some C++ code, which was
working also fine before. I wonder if these warning are causing the problem.
I would appreciate some help or suggestions on how to correct these. Thanks.
Warning 37 At least one of the arguments for...
|
by: TonyJ |
last post by:
Hello!
I get compile when using VS2005 but not in VS2003.
The compile error is the following
"Error 1 error C3867: 'MeltPracCommon::ReasonDialog::tbReason_TextChanged':
function call missing argument list; use
'&MeltPracCommon::ReasonDialog::tbReason_TextChanged' to create a pointer to
member c:\pk\development\products\utcas\4.0\src\commoncontrol\ReasonDialog.h
110"
|
by: BSand0764 |
last post by:
I'm getting an error that I can't seem to resolve. When I compile the
Functor related logic in a test program, the files compile and execute
properly (see Listing #1).
However, when I incorporate the same logic within my simulation, the
class that implements the functor logic has problems compiling. I get
the following errors:
-- Building myTest.cpp --
|
by: cpptutor2000 |
last post by:
Could someone please help me? I have the following C struct.
typedef struct
_FIREWALL_RULE_INFO
{
ULONG Precedence;
BOOL bEnabled;
BOOL bLoggingEnabled;
BOOL bAllowFragments;
BOOL bAllowInbound; /* only used
if 'SohoFirewallModel' is enabled */
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |