返回顶部

收藏

C++命令行应用使用 ACE 框架

更多

C代码

[STAThreadAttribute]
int main(array<:string> ^args)
{
 int result = ACE::init();
 if(result >= 0)
 {
  // Enabling Windows XP visual effects before any controls are created
  Application::EnableVisualStyles();
  Application::SetCompatibleTextRenderingDefault(false); 

  // Create the main window and run it
  Application::Run(gcnew MainForm());

  ACE::fini();

  }
  return result;
}

c++代码

#pragma once

#pragma managed(push,off)

typedef ACE_Future<int> IntFuture;

class ACEDotNetDemoTask : 
 public ACE_Task_Base
{
 ACE_Activation_Queue 
   activation_queue_;

public:
  ACEDotNetDemoTask(void);
  ~ACEDotNetDemoTask(void);

  virtual int svc (void);
  int enqueue (ACE_Method_Request *request);

  IntFuture call_exit();

};

typedef ACE_Singleton<ACEDotNetDemoTask, ACE_Null_Mutex> 
    ACEDOTNETDEMOTASK;

class ExitMethodRequest : 
 public ACE_Method_Request
 {
  IntFuture result_;
public:
 ExitMethodRequest(IntFuture& result)
  : result_(result)
 {
 ACE_TRACE ("ExitMethodRequest::ExitMethodRequest");
 }

 ~ExitMethodRequest( )
 {
  ACE_TRACE ("ExitMethodRequest::~ExitMethodRequest");
 }

 // Sets the value of the IntFuture to -1, and
 // returns -1 causing the svc method to exit.
 virtual int call (void)
 {
  ACE_TRACE ("ExitMethodRequest::call");
  int result = -1;
  result_.set(result);
  return result;
 }
};

#pragma managed(pop)

标签:c++,ACE

收藏

0人收藏

支持

0

反对

0

发表评论