Click here to Skip to main content
16,007,885 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: Sql server 2005 connection through VC++ Pin
maheesh22-Jan-09 2:26
maheesh22-Jan-09 2:26 
QuestionHow to open ms excel 2007 file in VC++ Pin
maheesh19-Jan-09 0:17
maheesh19-Jan-09 0:17 
AnswerRe: How to open ms excel 2007 file in VC++ Pin
staticv19-Jan-09 4:46
staticv19-Jan-09 4:46 
Questionwinsock not sending udp packet form multithreaded app.. Pin
IKoB18-Jan-09 11:49
IKoB18-Jan-09 11:49 
AnswerRe: winsock not sending udp packet form multithreaded app.. Pin
Christian Graus18-Jan-09 13:22
protectorChristian Graus18-Jan-09 13:22 
GeneralRe: winsock not sending udp packet form multithreaded app.. Pin
IKoB19-Jan-09 0:00
IKoB19-Jan-09 0:00 
GeneralRe: winsock not sending udp packet form multithreaded app.. Pin
N a v a n e e t h19-Jan-09 22:02
N a v a n e e t h19-Jan-09 22:02 
GeneralRe: winsock not sending udp packet form multithreaded app.. Pin
Mark Salsbery20-Jan-09 5:14
Mark Salsbery20-Jan-09 5:14 
QuestionProgramming over internet Pin
dSolariuM18-Jan-09 2:54
dSolariuM18-Jan-09 2:54 
Questionnetwork programming Pin
staticv16-Jan-09 8:07
staticv16-Jan-09 8:07 
AnswerRe: network programming Pin
N a v a n e e t h16-Jan-09 15:47
N a v a n e e t h16-Jan-09 15:47 
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 

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.