Esempio n. 1
0
        public async Task Load()
        {
            RuntimeCache wCache = new RuntimeCache();

            TaskCompletionSource <int> TCS = new TaskCompletionSource <int>();

            List <Announcements> News = new List <Announcements>();
            int i = 0;

            wCache.GET(
                new Uri(BULLETIN + BULLETIN_CH)
                , (DRequestCompletedEventArgs e, string id) =>
            {
                News.Add(new Announcements(e.ResponseString));
                if (++i == 2)
                {
                    TCS.SetResult(i);
                }
            }
                , (string id, string url, Exception ex) =>
            {
                PushItem();
                if (++i == 2)
                {
                    TCS.SetResult(i);
                }
            }
                , false);

            wCache.GET(
                new Uri(BULLETIN + BULLETIN_ALL)
                , (DRequestCompletedEventArgs e, string id) =>
            {
                News.Add(new Announcements(e.ResponseString));
                if (++i == 2)
                {
                    TCS.SetResult(i);
                }
            }
                , (string id, string url, Exception ex) =>
            {
                PushItem();
                if (++i == 2)
                {
                    TCS.SetResult(i);
                }
            }
                , false);


            await TCS.Task;

            foreach (Announcements A in News)
            {
                PushItem(A);
            }
        }
Esempio n. 2
0
        private async void OpenUrl_Click(object sender, RoutedEventArgs e)
        {
            StringResources stx = StringResources.Load("AdvDM");

            DownloadBookContext Context = new DownloadBookContext();

            wenku10.Pages.Dialogs.Rename UrlBox = new wenku10.Pages.Dialogs.Rename(Context, stx.Text("Download_Location"))
            {
                Placeholder = "http://example.com/NN. XXXX.txt"
            };

            await Popups.ShowDialog(UrlBox);

            if (UrlBox.Canceled)
            {
                return;
            }

            TaskCompletionSource <bool> TCS = new TaskCompletionSource <bool>();

            RuntimeCache rCache = new RuntimeCache();

            MessageBus.Send(GetType(), string.Format("{0}. {1}", Context.Id, Context.Title));

            rCache.GET(Context.Url, (DArgs, url) =>
            {
                SaveTemp(DArgs, Context);

                TCS.SetResult(true);
            }
                       , (id, url, ex) =>
            {
                Logger.Log(ID, ex.Message, LogType.WARNING);

                MessageBus.Send(GetType(), "Cannot download: " + id);
                TCS.SetResult(true);
            }, false);

            await PageExtOperations.Run(TCS.Task);
        }
Esempio n. 3
0
        public void LoadUrl( LocalModeTxtList.DownloadBookContext Context )
        {
            RuntimeCache rCache = new RuntimeCache();
            Logger.Log( ID, Context.Id, LogType.DEBUG );
            Logger.Log( ID, Context.Title, LogType.DEBUG );

            Worker.UIInvoke( () =>
            {
                StringResources stx = new StringResources( "AdvDM" );
                Loading = stx.Text( "Active" );
            } );

            rCache.GET( Context.Url, ( e, url ) =>
            {
                Loading = null;
                SaveTemp( e, Context );
            }
            , ( id, url, ex ) =>
            {
                Logger.Log( ID, "Cannot download: " + id, LogType.WARNING );
                Logger.Log( ID, ex.Message, LogType.WARNING );

            }, false );
        }