G
Guest
I am tring to start a thread where I am passing info into thread. According
to MS documentation I must do this by creating a class for that thread. I
have done this but am getting a compiler error. The error is:
c:\T02010_NET_ora9\cgi-bin\programs\TimeReader\TimeReaderWinService.cpp(104):
error C2475: 'ThreadWithState::readerThread' : forming a pointer-to-member
requires explicit use of the address-of operator ('&') and a qualified name
When I try to place '&' in what I believe is proper place I get a syntax
error on illegal use of '&'
I did have this line working before I tried to move it to this new class
with parameters. Below I have example of non working line and working line:
NON WORKING:
readThread = new Thread (new ThreadStart(this,
tws->ThreadWithState::readerThread));
WORKING:
readThread = new Thread (new
ThreadStart(this,&TimeReaderWinService::readerThread));
Below is a little more complete listing of code so you can see I have
declared things:
public __gc class TimeReaderWinService : public
System::ServiceProcess::ServiceBase
{
private:
Thread *readThread;
void readerThread (void);
protected:
/// <summary>
/// Set things in motion so your service can do its work.
/// </summary>
void OnStart(String* args[]);
private:
};
public __gc class ThreadWithState {
public:
ThreadWithState (Queue *queue_ptr);
void readerThread (void);
int ParseEmpcode (StreamWriter *fip, String*& empcode, String *data, int
track,
int leadskip, int tailskip, char skipzero);
// State information used in the task
private:
Queue *mySyncdQ;
};
void TimeReaderWinService::OnStart(String* args[])
{
Queue *myQ,
*mySyncdQ;
Thread *readThread;
myQ = new Queue();
mySyncdQ = Queue::Synchronized(myQ);
ThreadWithState *tws = new ThreadWithState (mySyncdQ);
// TODO: Add code here to start your service.
// Start a separate thread that does actual reading
if((readThread == NULL) || (readThread->ThreadState &
(System::Threading::ThreadState::Unstarted |
System::Threading::Stopped)) !=
(System::Threading::ThreadState)0) {
//This is the line that is having the problem
readThread = new Thread (new ThreadStart(this,
tws->ThreadWithState::readerThread));
// readThread = new Thread (new
ThreadStart(this,&TimeReaderWinService::readerThread));
readThread->Start();
}
}
to MS documentation I must do this by creating a class for that thread. I
have done this but am getting a compiler error. The error is:
c:\T02010_NET_ora9\cgi-bin\programs\TimeReader\TimeReaderWinService.cpp(104):
error C2475: 'ThreadWithState::readerThread' : forming a pointer-to-member
requires explicit use of the address-of operator ('&') and a qualified name
When I try to place '&' in what I believe is proper place I get a syntax
error on illegal use of '&'
I did have this line working before I tried to move it to this new class
with parameters. Below I have example of non working line and working line:
NON WORKING:
readThread = new Thread (new ThreadStart(this,
tws->ThreadWithState::readerThread));
WORKING:
readThread = new Thread (new
ThreadStart(this,&TimeReaderWinService::readerThread));
Below is a little more complete listing of code so you can see I have
declared things:
public __gc class TimeReaderWinService : public
System::ServiceProcess::ServiceBase
{
private:
Thread *readThread;
void readerThread (void);
protected:
/// <summary>
/// Set things in motion so your service can do its work.
/// </summary>
void OnStart(String* args[]);
private:
};
public __gc class ThreadWithState {
public:
ThreadWithState (Queue *queue_ptr);
void readerThread (void);
int ParseEmpcode (StreamWriter *fip, String*& empcode, String *data, int
track,
int leadskip, int tailskip, char skipzero);
// State information used in the task
private:
Queue *mySyncdQ;
};
void TimeReaderWinService::OnStart(String* args[])
{
Queue *myQ,
*mySyncdQ;
Thread *readThread;
myQ = new Queue();
mySyncdQ = Queue::Synchronized(myQ);
ThreadWithState *tws = new ThreadWithState (mySyncdQ);
// TODO: Add code here to start your service.
// Start a separate thread that does actual reading
if((readThread == NULL) || (readThread->ThreadState &
(System::Threading::ThreadState::Unstarted |
System::Threading::Stopped)) !=
(System::Threading::ThreadState)0) {
//This is the line that is having the problem
readThread = new Thread (new ThreadStart(this,
tws->ThreadWithState::readerThread));
// readThread = new Thread (new
ThreadStart(this,&TimeReaderWinService::readerThread));
readThread->Start();
}
}