示例#1
0
        private async Task StartUploadPhoto(string name, Stream stream)
        {
            try {
//                Deployment.Current.Dispatcher.BeginInvoke(() => {
//                    UploadProgressBar.Visibility = Visibility.Collapsed;
//                });
                logger.info("START upload photo");
                if (!(model is DialogModelPlain))
                {
                    return;
                }

                DialogModelPlain plainModel = (DialogModelPlain)model;

                InputFile file =
                    await TelegramSession.Instance.Files.UploadFile(name, stream, delegate { });

                InputMedia media = TL.inputMediaUploadedPhoto(file);
                logger.info("END upload photo");

                Deployment.Current.Dispatcher.BeginInvoke(() => {
                    logger.info("Send media in UI thread");

                    plainModel.SendMedia(media);
                });
//                Deployment.Current.Dispatcher.BeginInvoke(() => {
//                    UploadProgressBar.Visibility = Visibility.Collapsed;
//                });
            } catch (Exception ex) {
                logger.error("exception {0}", ex);
            }
        }