Пример #1
0
        private void initialize()
        {
            _messageSentCallback = MessageSentCallback;
            int ret;

            ret = Interop.Messages.OpenService(out _MessageServiceHandle);
            if (ret != (int)MessagesError.None)
            {
                Log.Error(Globals.LogTag, "Failed to open service, Error - " + (MessagesError)ret);
            }
        }
Пример #2
0
        internal Task <SentResult> SendMessageAsync(Message message, bool saveToSentbox)
        {
            var task = new TaskCompletionSource <SentResult>();

            _messageSentCallback = (int result, IntPtr data) =>
            {
                task.SetResult((SentResult)result);
            };

            message.FillHandle();

            int    ret;
            IntPtr messageHandle = message.GetHandle();

            ret = Interop.Messages.SendMessage(_MessageServiceHandle, messageHandle, saveToSentbox, _messageSentCallback, IntPtr.Zero);
            if (ret != (int)MessagesError.None)
            {
                Log.Error(Globals.LogTag, "Failed to send message, Error - " + (MessagesError)ret);
                MessagesErrorFactory.ThrowMessagesException(ret, _MessageServiceHandle);
            }

            return(task.Task);
        }