當前位置: 首頁>>代碼示例>>C#>>正文


C# MamaMsg.SelfManageLifeTime方法代碼示例

本文整理匯總了C#中Wombat.MamaMsg.SelfManageLifeTime方法的典型用法代碼示例。如果您正苦於以下問題:C# MamaMsg.SelfManageLifeTime方法的具體用法?C# MamaMsg.SelfManageLifeTime怎麽用?C# MamaMsg.SelfManageLifeTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Wombat.MamaMsg的用法示例。


在下文中一共展示了MamaMsg.SelfManageLifeTime方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: getMsg

        /// <summary>
        /// Get a submessage.
        /// </summary>
        public MamaMsg getMsg(
			string name, 
			ushort fid)
        {
            if (msg_ == null)
            {
                msg_ = new MamaMsg ();
                msg_.SelfManageLifeTime(false);
            }
            tryMsgImpl(name, fid, ref msg_, true);
            return msg_;
        }
開發者ID:OpenMAMA,項目名稱:OpenMAMA,代碼行數:15,代碼來源:MamaMsg.cs

示例2: sendFromInboxWithThrottle

		/// <summary>
		/// Send a p2p message from the specified inbox using the throttle.
		/// The lifecycle of the message sent is controlled by the user of the API. The
		/// callback indicates when the API is no longer using the message and can be
		/// destroyed/reused by the application.
		/// </summary>
		/// <param name="inbox">The MamaInbox which will process any response to the sent message.</param>
		/// <param name="message">The MamaMsg to send.</param>
		/// <param name="callback">The callback which will be invoked when the message
		/// is sent from the throttle queue.</param>
		/// <param name="closure">User supplied data returned when the callback is invoked.</param>
		public void sendFromInboxWithThrottle(
			MamaInbox inbox,
			MamaMsg message,
			MamaSendCompleteCallback callback,
			object closure)
		{
#if MAMA_WRAPPERS_CHECK_ARGUMENTS
			if (inbox == null)
			{
				throw new ArgumentNullException("inbox");
			}
			if (message == null)
			{
				throw new ArgumentNullException("message");
			}
			if (callback == null)
			{
				throw new ArgumentNullException("callback");
			}
			EnsurePeerCreated();
#endif // MAMA_WRAPPERS_CHECK_ARGUMENTS

            // Create a new callback wrapper
            MamaCallbackWrapper<MamaSendCompleteCallback, MamaThrottledSendCompleteDelegate> wrapper =
                new MamaCallbackWrapper<MamaSendCompleteCallback, MamaThrottledSendCompleteDelegate>(
                    callback,
                    closure,
                    new MamaThrottledSendCompleteDelegate(onSendComplete));

            // Add this to the store
            IntPtr nativeClosure = mCallbackStore.StoreWrapper(wrapper);

			// Call the native function
			int code = NativeMethods.mamaPublisher_sendFromInboxWithThrottle(
				nativeHandle,
                inbox.NativeHandle,
				message.NativeHandle, 
                (Wombat.MamaPublisher.MamaThrottledSendCompleteDelegate)wrapper.NativeDelegate,
                nativeClosure);
			try
			{
				CheckResultCode(code);
			}

            // If something goes wrong then remove the wrapper from the store
			catch
			{
                // Remove the wrapper
                mCallbackStore.RemoveWrapper(nativeClosure);

                // Dispose it
                ((IDisposable)wrapper).Dispose();
                
                // Rethrow the exception
				throw;
			}
		
            // Ensure that the message passed will not delete its native peer
            message.SelfManageLifeTime(false);
		}
開發者ID:jacobraj,項目名稱:MAMA,代碼行數:71,代碼來源:MamaPublisher.cs


注:本文中的Wombat.MamaMsg.SelfManageLifeTime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。