
| public ref class ReferenceType {}; |
| public ref class ReferenceType { public: //程序集内部与外部均可见 private public: //只对程序集内部可见 protected public: //对程序集内所有代码可见;对外部继承类型可见 }; |
| public string Name { get { return m_name; } set { m_name = value; } } |
| __property String* get_Name() { return m_value; } __property String* set_Name(String* value) { m_value = value; } |
| property String^ Name { String^ get() { return m_value; } void set(String^ value) { m_value = value; } } |
| property String^ Name { public: String^ get(); private public: void set(String^); } |
| property String^ Name; |
| class ThreadPool { public: template <typename T> static void QueueUserWorkItem(void (T::*function)(), T* object) { typedef std::pair<void (T::*)(), T*> CallbackType; std::auto_ptr<CallbackType> p(new CallbackType(function, object)); if (::QueueUserWorkItem(ThreadProc<T>, p.get(), WT_EXECUTEDEFAULT)) { //ThreadProc负责删除pair. p.release(); } else { AtlThrowLastWin32(); } } private: template <typename T> static DWORD WINAPI ThreadProc(PVOID context) { typedef std::pair<void (T::*)(), T*> CallbackType; std::auto_ptr<CallbackType> p(static_cast<CallbackType*>(context)); (p->second->*p->first)(); return 0; } ThreadPool(); }; |
| class Service { public: void AsyncRun() { ThreadPool::QueueUserWorkItem(Run, this); } void Run() { //其他代码 } } |
| delegate void Function(); |
| ref struct ReferenceType { void InstanceMethod() {} static void StaticMethod() {} }; //创建代理并绑定到成员函数的实例 Function^ f = gcnew Function(gcnew ReferenceType, ReferenceType::InstanceMethod); //也可绑定到静态成员函数,并结合几个代理形成代理链 f += gcnew Function(ReferenceType::StaticMethod); //调用函数 f(); |
| 关于我们 | 联系我们 | 广告服务 | 工作机会 | 版权声明 | 欢迎投稿 | 网站地图 |
| Copyright © 2000-2008 , www.21tx.com , All Rights Reserved . |
| © 晨新科技 版权所有 Created by TXSite.net |