Click here to Skip to main content
15,896,154 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: network programming Pin
staticv16-Jan-09 20:23
staticv16-Jan-09 20:23 
GeneralRe: network programming Pin
Tony Pottier17-Feb-09 4:31
Tony Pottier17-Feb-09 4:31 
GeneralRe: network programming Pin
staticv17-Feb-09 4:44
staticv17-Feb-09 4:44 
QuestionProblem of visual c++ to Automate Excel [modified] Pin
sai5616-Jan-09 0:43
sai5616-Jan-09 0:43 
Questioncrystal report Pin
S.M.kanerkar13-Jan-09 20:11
S.M.kanerkar13-Jan-09 20:11 
QuestionThe c# 'using' statement in managed c++ Pin
TheBerk13-Jan-09 9:25
TheBerk13-Jan-09 9:25 
AnswerRe: The c# 'using' statement in managed c++ Pin
Mark Salsbery13-Jan-09 11:09
Mark Salsbery13-Jan-09 11:09 
Questionthread deadlock Pin
staticv12-Jan-09 5:02
staticv12-Jan-09 5:02 
using namespace System;
using namespace System::Threading;

ref class MyThread
{
public:
    static void ThreadFunc1();
    static void ThreadFunc2();
};

void MyThread::ThreadFunc1()
{
    Console::WriteLine("Before long sleep");
    try
    {
        Thread::Sleep(Timeout::Infinite); 
    }
    catch(ThreadInterruptedException^){/*continue processing*/}
    Console::WriteLine("After long sleep");
}

void MyThread::ThreadFunc2()
{
    for (int i = 0; i < 5; i++)
    {
        Console::WriteLine("Thread {0}",i.ToString());
        Thread::Sleep(2);
    }
}


void main()
{
    Thread ^thr1 = gcnew Thread(gcnew ThreadStart(&MyThread::ThreadFunc1));
    Thread ^thr2 = gcnew Thread(gcnew ThreadStart(&MyThread::ThreadFunc2));

    Console::WriteLine("Sleep/interrupt thread");
    thr1->Start();
    
    Thread::Sleep(4);
    for (int i = 0; i < 4; i++)
    {
          Console::WriteLine("**Main2 {0}", i.ToString());
          Thread::Sleep(2);
    }
    thr1->Interrupt();
    thr1->Join();

    Console::WriteLine("\nSuspend/resume thread");
    thr2->Start();

    Thread::Sleep(8);
    thr2->Suspend();

    for (int i = 0; i < 4; i++)
    {
        Console::WriteLine("**Main1 {0}", i.ToString());
        Thread::Sleep(2);
    }
    thr2->Resume();
}


This program hangs sometimes, so I'm sure there is a deadlock between the threads but I can't catch it.

It mainly stops in the code highlighted...

Top Web Hosting Providers[^]

Do, or do not. There is no 'try'.

GeneralRe: thread deadlock Pin
Luc Pattyn12-Jan-09 6:50
sitebuilderLuc Pattyn12-Jan-09 6:50 
GeneralRe: thread deadlock [modified] Pin
staticv12-Jan-09 23:29
staticv12-Jan-09 23:29 
GeneralRe: thread deadlock Pin
Luc Pattyn13-Jan-09 2:44
sitebuilderLuc Pattyn13-Jan-09 2:44 
GeneralRe: thread deadlock Pin
staticv13-Jan-09 2:59
staticv13-Jan-09 2:59 
GeneralRe: thread deadlock Pin
Luc Pattyn13-Jan-09 3:06
sitebuilderLuc Pattyn13-Jan-09 3:06 
QuestionMixing managed/unmanaged in C++/CLI Pin
Jon Hulatt12-Jan-09 1:38
Jon Hulatt12-Jan-09 1:38 
AnswerRe: Mixing managed/unmanaged in C++/CLI Pin
N a v a n e e t h12-Jan-09 1:47
N a v a n e e t h12-Jan-09 1:47 
GeneralRe: Mixing managed/unmanaged in C++/CLI Pin
Jon Hulatt12-Jan-09 1:49
Jon Hulatt12-Jan-09 1:49 
GeneralRe: Mixing managed/unmanaged in C++/CLI Pin
N a v a n e e t h12-Jan-09 2:08
N a v a n e e t h12-Jan-09 2:08 
AnswerRe: Mixing managed/unmanaged in C++/CLI Pin
teejayem12-Jan-09 9:28
teejayem12-Jan-09 9:28 
Questionthread.Abort() Pin
staticv12-Jan-09 0:53
staticv12-Jan-09 0:53 
AnswerRe: thread.Abort() [modified] Pin
N a v a n e e t h12-Jan-09 2:17
N a v a n e e t h12-Jan-09 2:17 
GeneralRe: thread.Abort() Pin
staticv12-Jan-09 2:44
staticv12-Jan-09 2:44 
GeneralRe: thread.Abort() Pin
N a v a n e e t h12-Jan-09 2:56
N a v a n e e t h12-Jan-09 2:56 
GeneralRe: thread.Abort() Pin
staticv12-Jan-09 2:58
staticv12-Jan-09 2:58 
GeneralRe: thread.Abort() Pin
N a v a n e e t h12-Jan-09 3:11
N a v a n e e t h12-Jan-09 3:11 
QuestionProblem about the visual 2008 c++ Pin
sai5611-Jan-09 21:39
sai5611-Jan-09 21:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.