5 个解决方案
#1
编译选项,加上clr。
公共语言运行库
公共语言运行库
#2
改了还是出错
------ 已启动生成: 项目: threadpool, 配置: Debug Win32 ------
正在编译...
cl: 命令行 error D8016 :“/RTC1”和“/clr”命令行选项不兼容
项目 : error PRJ0002 : 错误的结果 2 (从“D:\Program Files\Microsoft Visual Studio 9.0\VC\bin\cl.exe”返回)。
生成日志保存在“file://c:\Documents and Settings\cx2007\My Documents\Visual Studio 2008\Projects\threadpool\threadpool\Debug\BuildLog.htm”
threadpool - 1 个错误,0 个警告
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
------ 已启动生成: 项目: threadpool, 配置: Debug Win32 ------
正在编译...
cl: 命令行 error D8016 :“/RTC1”和“/clr”命令行选项不兼容
项目 : error PRJ0002 : 错误的结果 2 (从“D:\Program Files\Microsoft Visual Studio 9.0\VC\bin\cl.exe”返回)。
生成日志保存在“file://c:\Documents and Settings\cx2007\My Documents\Visual Studio 2008\Projects\threadpool\threadpool\Debug\BuildLog.htm”
threadpool - 1 个错误,0 个警告
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
#3
我是从msdn上找到的一个线程池的实例:但是用不了
using namespace System;
using namespace System::Threading;
ref class Example
{
public:
// This thread procedure performs the task.
static void ThreadProc( Object^ stateInfo )
{
// No state object was passed to QueueUserWorkItem, so
// stateInfo is 0.
Console::WriteLine( "Hello from the thread pool." );
}
};
int main()
{
// Queue the task.
ThreadPool::QueueUserWorkItem( gcnew WaitCallback( Example::ThreadProc ) );
Console::WriteLine( "Main thread does some work, then sleeps." );
// If you comment out the Sleep, the main thread exits before
// the thread pool task runs. The thread pool uses background
// threads, which do not keep the application running. (This
// is a simple example of a race condition.)
Thread::Sleep( 1000 );
Console::WriteLine( "Main thread exits." );
return 0;
}
using namespace System;
using namespace System::Threading;
ref class Example
{
public:
// This thread procedure performs the task.
static void ThreadProc( Object^ stateInfo )
{
// No state object was passed to QueueUserWorkItem, so
// stateInfo is 0.
Console::WriteLine( "Hello from the thread pool." );
}
};
int main()
{
// Queue the task.
ThreadPool::QueueUserWorkItem( gcnew WaitCallback( Example::ThreadProc ) );
Console::WriteLine( "Main thread does some work, then sleeps." );
// If you comment out the Sleep, the main thread exits before
// the thread pool task runs. The thread pool uses background
// threads, which do not keep the application running. (This
// is a simple example of a race condition.)
Thread::Sleep( 1000 );
Console::WriteLine( "Main thread exits." );
return 0;
}
#4
你创建一个clr 控制台工程,再试试
#5
果然能成功了。
不过我要用wtl,或者其他工程就用不了
不过我要用wtl,或者其他工程就用不了
#1
编译选项,加上clr。
公共语言运行库
公共语言运行库
#2
改了还是出错
------ 已启动生成: 项目: threadpool, 配置: Debug Win32 ------
正在编译...
cl: 命令行 error D8016 :“/RTC1”和“/clr”命令行选项不兼容
项目 : error PRJ0002 : 错误的结果 2 (从“D:\Program Files\Microsoft Visual Studio 9.0\VC\bin\cl.exe”返回)。
生成日志保存在“file://c:\Documents and Settings\cx2007\My Documents\Visual Studio 2008\Projects\threadpool\threadpool\Debug\BuildLog.htm”
threadpool - 1 个错误,0 个警告
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
------ 已启动生成: 项目: threadpool, 配置: Debug Win32 ------
正在编译...
cl: 命令行 error D8016 :“/RTC1”和“/clr”命令行选项不兼容
项目 : error PRJ0002 : 错误的结果 2 (从“D:\Program Files\Microsoft Visual Studio 9.0\VC\bin\cl.exe”返回)。
生成日志保存在“file://c:\Documents and Settings\cx2007\My Documents\Visual Studio 2008\Projects\threadpool\threadpool\Debug\BuildLog.htm”
threadpool - 1 个错误,0 个警告
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
#3
我是从msdn上找到的一个线程池的实例:但是用不了
using namespace System;
using namespace System::Threading;
ref class Example
{
public:
// This thread procedure performs the task.
static void ThreadProc( Object^ stateInfo )
{
// No state object was passed to QueueUserWorkItem, so
// stateInfo is 0.
Console::WriteLine( "Hello from the thread pool." );
}
};
int main()
{
// Queue the task.
ThreadPool::QueueUserWorkItem( gcnew WaitCallback( Example::ThreadProc ) );
Console::WriteLine( "Main thread does some work, then sleeps." );
// If you comment out the Sleep, the main thread exits before
// the thread pool task runs. The thread pool uses background
// threads, which do not keep the application running. (This
// is a simple example of a race condition.)
Thread::Sleep( 1000 );
Console::WriteLine( "Main thread exits." );
return 0;
}
using namespace System;
using namespace System::Threading;
ref class Example
{
public:
// This thread procedure performs the task.
static void ThreadProc( Object^ stateInfo )
{
// No state object was passed to QueueUserWorkItem, so
// stateInfo is 0.
Console::WriteLine( "Hello from the thread pool." );
}
};
int main()
{
// Queue the task.
ThreadPool::QueueUserWorkItem( gcnew WaitCallback( Example::ThreadProc ) );
Console::WriteLine( "Main thread does some work, then sleeps." );
// If you comment out the Sleep, the main thread exits before
// the thread pool task runs. The thread pool uses background
// threads, which do not keep the application running. (This
// is a simple example of a race condition.)
Thread::Sleep( 1000 );
Console::WriteLine( "Main thread exits." );
return 0;
}
#4
你创建一个clr 控制台工程,再试试
#5
果然能成功了。
不过我要用wtl,或者其他工程就用不了
不过我要用wtl,或者其他工程就用不了