Jump to content

error C3867 - Please Help to solve it

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
benshrupendra

benshrupendra

    Newbie

  • Members
  • Pip
  • 3 posts


Hello all friend.

I have some problem in mention below code and I got an error from it.


#include "stdafx.h"


namespace wyUpdate

{

	using namespace System;

	using namespace System::Collections::Generic;

	using namespace System::IO;

	using namespace System::Runtime::InteropServices;

	using namespace System::Threading;

	using namespace Microsoft::Win32::SafeHandles;

	

/// <summary>

	/// Allow pipe communication between a server and a client

	/// </summary>

	public ref class PipeServer

	{

	

		public:

			[StructLayoutAttribute(LayoutKind::Sequential)]

			value class SECURITY_DESCRIPTOR

			{

				public:

					System::Byte revision;

					System::Byte size;

					short control;

					IntPtr owner;

					IntPtr group;

					IntPtr sacl;

					IntPtr dacl;

			};


		public:

			[StructLayout(LayoutKind::Sequential)]

			value class SECURITY_ATTRIBUTES

			{

			public:

				int nLength;

				IntPtr lpSecurityDescriptor;

				int bInheritHandle;

			};


		private:

			literal System::UInt32 SECURITY_DESCRIPTOR_REVISION = 1;


		

		public:

			ref class Client

			{

				public:

					SafeFileHandle ^handle;

					FileStream ^stream;

			};


		Thread ^listenThread;

		static initonly List<Client^> ^clients = gcnew List<Client^>();


		public:

			void Start(System::String ^pipename)

			{

				PipeName = pipename;


				[B][COLOR="red"]listenThread = gcnew Thread(ListenForClients);[/COLOR][/B]

				listenThread->Start();


				Running = true;

			}


		public:

			void ListenForClients()

			{

			   SECURITY_DESCRIPTOR ^sd = gcnew SECURITY_DESCRIPTOR();

			}


	};	

}




Error is :
error C3867: 'wyUpdate::PipeServer::ListenForClients': function call missing argument list; use '&wyUpdate::PipeServer::ListenForClients' to create a pointer to member


But when I use mention below code instead of it:

listenThread = gcnew Thread(&ListenForClients);

I got mention below error:
error C2276: '&' : illegal operation on bound member function expression


Please help me to solve it.

Thank you in advance,

Rupendra


#2
mnirahd

mnirahd

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 330 posts
Hi,

I think you're creating thread properly: refer to following code:it may help!


// [C++]

// Compile using /clr option.

using namespace System;

using namespace System::Threading;


// Simple threading scenario:  Start a Shared method running

// on a second thread.

public ref class ThreadExample

{

public:


   // The ThreadProc method is called when the thread starts.

   // It loops ten times, writing to the console and yielding 

   // the rest of its time slice each time, and then ends.

   static void ThreadProc()

   {

      for ( int i = 0; i < 10; i++ )

      {

         Console::Write(  "ThreadProc: " );

         Console::WriteLine( i );


         // Yield the rest of the time slice.

         Thread::Sleep( 0 );


      }

   }


};


int main()

{

   Console::WriteLine( "Main thread: Start a second thread." );


   // Create the thread, passing a ThreadStart delegate that

   // represents the ThreadExample::ThreadProc method.  For a 

   // delegate representing a static method, no object is

   // required.

   Thread^ oThread = gcnew Thread( gcnew ThreadStart( &ThreadExample::ThreadProc ) );


   // Start ThreadProc.  Note that on a uniprocessor, the new 

   // thread does not get any processor time until the main thread 

   // is preempted or yields.  Uncomment the Thread::Sleep that 

   // follows oThread->Start() to see the difference.

   oThread->Start();


   //Thread::Sleep(0);

   for ( int i = 0; i < 4; i++ )

   {

      Console::WriteLine(  "Main thread: Do some work." );

      Thread::Sleep( 0 );


   }

   Console::WriteLine(  "Main thread: Call Join(), to wait until ThreadProc ends." );

   oThread->Join();

   Console::WriteLine(  "Main thread: ThreadProc.Join has returned.  Press Enter to end program." );

   Console::ReadLine();

   return 0;

}




-Munir