예제 #1
0
        private void ForecastButtonHandler(object sender, RoutedEventArgs e)
        {
            // Change the status image and start the rotation animation.
            fetchButton.IsEnabled = false;
            fetchButton.Content = "Contacting Server";
            weatherText.Text = "";
            _hideWeatherImageStoryboard.Begin(this);

            // Start fetching the weather forecast asynchronously.
            var fetcher = new NoArgDelegate(
                FetchWeatherFromServer);

            fetcher.BeginInvoke(null, null);
        }
        void BeginExecuteTestAsync()
        {
            Debug.Assert(this.IsRunningOnWorkerThread);

            NoArgDelegate testMethod = new NoArgDelegate(this.ExecuteTestAsync);

            // The call to ExecuteTestAsync must be delayed so
            // that the worker thread's Dispatcher can be started
            // before the method executes.  This is needed because
            // the Dispatcher.Run method does not return until the
            // Dispatcher has been shut down.
            Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Normal, testMethod);

            // Start the worker thread's message pump so that
            // queued messages are processed.
            Dispatcher.Run();
        }
예제 #3
0
        private void btnRetrieveData_Click(object sender, RoutedEventArgs e)
        {
            this.btnRetrieveData.IsEnabled = false;
            this.btnRetrieveData.Content = "Contacting Server";

            NoArgDelegate fetcher = new NoArgDelegate(
                this.RetrieveDataFromServer);
            fetcher.BeginInvoke(null, null);
        }
 public void RunConferencService()
 {
     NoArgDelegate executor = new NoArgDelegate(this.runConferencService);
     executor.BeginInvoke(null, null);
 }
예제 #5
0
        private void startButton_Click(object sender, RoutedEventArgs e)
        {
            if (!gameCreated)
            {
                MessageBoxResult result;
                result = MessageBox.Show("Would you like to play in the game?", "Participation Option", MessageBoxButton.YesNo);
                if (result == MessageBoxResult.Yes)
                {
                    this.humanIsPlaying = true;
                    this.game = new GameController(3, this);
                }
                else
                {
                    this.humanIsPlaying = false;
                    this.game = new GameController(2, this);
                }
                this.game.addGameObserver(this);
                this.initializeGame();

                // Start the game
                NoArgDelegate mainGameDel = new NoArgDelegate(this.game.beginGame);
                mainGameDel.BeginInvoke(null, null);

            }
            else
            {
                this.initializeGame();

                NoArgDelegate repeatedGameDel = new NoArgDelegate(this.game.playAgain);
                repeatedGameDel.BeginInvoke(null, null);

            }
        }
예제 #6
0
파일: Program.cs 프로젝트: kazuki/oclcrypto
 static TimeSpan Execute(string msg, int loops, int input_length, NoArgDelegate func, NoArgDelegate prepFunc)
 {
     long min = long.MaxValue;
     for (int i = 0; i < loops; i++) {
         if (prepFunc != null)
             prepFunc ();
         Stopwatch sw = Stopwatch.StartNew ();
         func ();
         sw.Stop ();
         min = Math.Min (min, sw.Elapsed.Ticks);
     }
     TimeSpan ret = TimeSpan.FromTicks (min);
     WriteTime (msg, ret, input_length);
     return ret;
 }
예제 #7
0
파일: Program.cs 프로젝트: kazuki/oclcrypto
 static TimeSpan Execute(string msg, int loops, int input_length, NoArgDelegate func)
 {
     return Execute (msg, loops, input_length, func, null);
 }
 public void RunConferencService()
 {
     //ThreadPool.QueueUserWorkItem(new WaitCallback(runConferencService));
     NoArgDelegate executor = new NoArgDelegate(this.runConferencService);
     executor.BeginInvoke(null, null);
 }
예제 #9
0
        private void DispatchFriendsList()
        {
            NoArgDelegate fetcher = new NoArgDelegate(this.GetFirends);

            fetcher.BeginInvoke(null, null);
        }
예제 #10
0
        private void DelegateRecentFetch()
        {
            // Let the user know what's going on
            //StatusTextBlock.Text = "Retrieving tweets...";

            //PlayStoryboard("Fetching");

            // Create a Dispatcher to fetching new tweets
            NoArgDelegate fetcher = new NoArgDelegate(
                this.GetTweets);

            fetcher.BeginInvoke(null, null);
        }
예제 #11
0
        private void DisplayLoginIfUserNotLoggedIn()
        {
            // Does the user need to login?
            if (string.IsNullOrEmpty(AppSettings.Username))
            {
                PlayStoryboard("ShowLogin");
            }
            else
            {
                LoginControl.Visibility = Visibility.Hidden;

                System.Security.SecureString password = TwitterNet.DecryptString(AppSettings.Password);

                // Jason Follas: Reworked Web Proxy - don't need to explicitly pass into TwitterNet ctor
                //twitter = new TwitterNet(AppSettings.Username, password, WebProxyHelper.GetConfiguredWebProxy());
                twitter = new TwitterNet(AppSettings.Username, password);

                // Jason Follas: Twitter proxy servers, anyone?  (Network Nazis who block twitter.com annoy me)
                twitter.TwitterServerUrl = AppSettings.TwitterHost;

                // Let the user know what's going on
                StatusTextBlock.Text = Properties.Resources.TryLogin;
                PlayStoryboard("Fetching");

                // Create a Dispatcher to attempt login on new thread
                NoArgDelegate loginFetcher = new NoArgDelegate(this.TryLogin);
                loginFetcher.BeginInvoke(null, null);

            }
        }
예제 #12
0
        private void DelegateMessagesFetch()
        {
            // Let the user know what's going on
            StatusTextBlock.Text = "Retrieving direct messages...";

            PlayStoryboard("Fetching");

            // Create a Dispatcher to fetching new tweets
            NoArgDelegate fetcher = new NoArgDelegate(
                this.GetMessages);

            fetcher.BeginInvoke(null, null);
        }
예제 #13
0
 public abstract void Enter(NoArgDelegate callback = null);