Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Threading Problem

Threading Problem

Scheduled Pinned Locked Moved Managed C++/CLI
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    erfi
    wrote on last edited by
    #1

    hi. i have a class like this :

    public ref class MyClass : public IDisposable
    {
    .
    .
    .
    public: MyClass();
    private: void Wait();
    .
    .
    .
    }

    and the cpp file:

    MyClass::MyClass()
    {
    // Create a new thread to wait for events
    Thread^ t = gcnew Thread(gcnew ThreadStart(&MyClass::Wait));
    t->Name = "Event Thread";
    t->Start();
    }

    in compile i got this error : "error C3350: 'System::Threading::ThreadStart' : a delegate constructor expects 2 argument(s)" I've looked in msdn and saw a example that exactly used this way for threading but there was no error in compilation. thank you for help.

    sometimes 0 can be 1

    L M 2 Replies Last reply
    0
    • E erfi

      hi. i have a class like this :

      public ref class MyClass : public IDisposable
      {
      .
      .
      .
      public: MyClass();
      private: void Wait();
      .
      .
      .
      }

      and the cpp file:

      MyClass::MyClass()
      {
      // Create a new thread to wait for events
      Thread^ t = gcnew Thread(gcnew ThreadStart(&MyClass::Wait));
      t->Name = "Event Thread";
      t->Start();
      }

      in compile i got this error : "error C3350: 'System::Threading::ThreadStart' : a delegate constructor expects 2 argument(s)" I've looked in msdn and saw a example that exactly used this way for threading but there was no error in compilation. thank you for help.

      sometimes 0 can be 1

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      erfi wrote:

      I've looked in msdn and saw a example that exactly used this way for threading

      So why didn't you post a link to the documentation you claim to have seen? Try looking at the example code in this documentation[^]

      1 Reply Last reply
      0
      • E erfi

        hi. i have a class like this :

        public ref class MyClass : public IDisposable
        {
        .
        .
        .
        public: MyClass();
        private: void Wait();
        .
        .
        .
        }

        and the cpp file:

        MyClass::MyClass()
        {
        // Create a new thread to wait for events
        Thread^ t = gcnew Thread(gcnew ThreadStart(&MyClass::Wait));
        t->Name = "Event Thread";
        t->Start();
        }

        in compile i got this error : "error C3350: 'System::Threading::ThreadStart' : a delegate constructor expects 2 argument(s)" I've looked in msdn and saw a example that exactly used this way for threading but there was no error in compilation. thank you for help.

        sometimes 0 can be 1

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        erfi wrote:

        I've looked in msdn and saw a example that exactly used this way

        Exactly? I have a feeling the Wait() function was static in the example. Using a non-static function as you've shown won't work because a MyClass object (instance) is required to make the call to Wait(). You'd have to pass an instance to the delegate constructor. Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups