• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ProgressHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ProgressHandler的典型用法代码示例。如果您正苦于以下问题:C# ProgressHandler类的具体用法?C# ProgressHandler怎么用?C# ProgressHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ProgressHandler类属于命名空间,在下文中一共展示了ProgressHandler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Fetch

        /// <summary>
        ///   Fetch from the <see cref = "Remote" />.
        /// </summary>
        /// <param name="remote">The remote to fetch</param>
        /// <param name="tagFetchMode">Optional parameter indicating what tags to download.</param>
        /// <param name="onProgress">Progress callback. Corresponds to libgit2 progress callback.</param>
        /// <param name="onCompletion">Completion callback. Corresponds to libgit2 completion callback.</param>
        /// <param name="onUpdateTips">UpdateTips callback. Corresponds to libgit2 update_tips callback.</param>
        /// <param name="onTransferProgress">Callback method that transfer progress will be reported through.
        ///   Reports the client's state regarding the received and processed (bytes, objects) from the server.</param>
        /// <param name="credentials">Credentials to use for username/password authentication.</param>
        public virtual void Fetch(
            Remote remote,
            TagFetchMode tagFetchMode = TagFetchMode.Auto,
            ProgressHandler onProgress = null,
            CompletionHandler onCompletion = null,
            UpdateTipsHandler onUpdateTips = null,
            TransferProgressHandler onTransferProgress = null,
            Credentials credentials = null)
        {
            Ensure.ArgumentNotNull(remote, "remote");

            // We need to keep a reference to the git_cred_acquire_cb callback around
            // so it will not be garbage collected before we are done with it.
            // Note that we also have a GC.KeepAlive call at the end of the method.
            NativeMethods.git_cred_acquire_cb credentialCallback = null;

            using (RemoteSafeHandle remoteHandle = Proxy.git_remote_load(repository.Handle, remote.Name, true))
            {
                var callbacks = new RemoteCallbacks(onProgress, onCompletion, onUpdateTips);
                GitRemoteCallbacks gitCallbacks = callbacks.GenerateCallbacks();

                Proxy.git_remote_set_autotag(remoteHandle, tagFetchMode);

                if (credentials != null)
                {
                    credentialCallback = (out IntPtr cred, IntPtr url, IntPtr username_from_url, uint types, IntPtr payload) =>
                        NativeMethods.git_cred_userpass_plaintext_new(out cred, credentials.Username, credentials.Password);

                    Proxy.git_remote_set_cred_acquire_cb(
                        remoteHandle,
                        credentialCallback,
                        IntPtr.Zero);
                }

                // It is OK to pass the reference to the GitCallbacks directly here because libgit2 makes a copy of
                // the data in the git_remote_callbacks structure. If, in the future, libgit2 changes its implementation
                // to store a reference to the git_remote_callbacks structure this would introduce a subtle bug
                // where the managed layer could move the git_remote_callbacks to a different location in memory,
                // but libgit2 would still reference the old address.
                //
                // Also, if GitRemoteCallbacks were a class instead of a struct, we would need to guard against
                // GC occuring in between setting the remote callbacks and actual usage in one of the functions afterwords.
                Proxy.git_remote_set_callbacks(remoteHandle, ref gitCallbacks);

                try
                {
                    Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch);
                    Proxy.git_remote_download(remoteHandle, onTransferProgress);
                    Proxy.git_remote_update_tips(remoteHandle);
                }
                finally
                {
                    Proxy.git_remote_disconnect(remoteHandle);
                }
            }

            // To be safe, make sure the credential callback is kept until
            // alive until at least this point.
            GC.KeepAlive(credentialCallback);
        }
开发者ID:TiThompson,项目名称:libgit2sharp,代码行数:71,代码来源:Network.cs


示例2: OnCreate

        private ProgressBar progressBar; // Progress spinner to use for table operations

        // Called when the activity initially gets created
		protected override async void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);

			// Set our view from the "main" layout resource
			SetContentView(Resource.Layout.Activity_To_Do);

            // Initialize the progress bar
			progressBar = FindViewById<ProgressBar>(Resource.Id.loadingProgressBar);
			progressBar.Visibility = ViewStates.Gone;

			// Create ProgressFilter to handle busy state
			var progressHandler = new ProgressHandler ();
			progressHandler.BusyStateChange += (busy) => {
				if (progressBar != null) 
					progressBar.Visibility = busy ? ViewStates.Visible : ViewStates.Gone;
			};

			try 
            {
                // PUSH NOTIFICATIONS: Register for push notifications
                System.Diagnostics.Debug.WriteLine("Registering...");
				// Initialize our Gcm Service Hub
				GcmService.Initialize(this);
				GcmService.Register(this);


				// MOBILE SERVICES: Setup azure mobile services - this is separate from push notifications
				CurrentPlatform.Init ();
				// Create the Mobile Service Client instance, using the provided
				// Mobile Service URL and key
				client = new MobileServiceClient(
					Constants.ApplicationURL,
					Constants.ApplicationKey, progressHandler);

				// Get the Mobile Service Table instance to use
				todoTable = client.GetTable<TodoItem>();


				// USER INTERFACE: setup the Android UI
				textNewTodo = FindViewById<EditText>(Resource.Id.textNewTodo);

				// Create an adapter to bind the items with the view
				adapter = new TodoItemAdapter(this, Resource.Layout.Row_List_To_Do);
				var listViewTodo = FindViewById<ListView>(Resource.Id.listViewTodo);
				listViewTodo.Adapter = adapter;

				// Load the items from the Mobile Service
				await RefreshItemsFromTableAsync();
			} 
            catch (Java.Net.MalformedURLException) 
            {
				CreateAndShowDialog(new Exception ("There was an error creating the Mobile Service. Verify the URL"), "Error");
			} 
            catch (Exception e) 
            {
				CreateAndShowDialog(e, "Error");
			}
		}
开发者ID:ARMoir,项目名称:mobile-samples,代码行数:62,代码来源:TodoActivity.cs


示例3: OnCreate

        private ProgressBar progressBar; // Progress spinner to use for table operations

        // Called when the activity initially gets created
		protected override async void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);

			// Set our view from the "main" layout resource
			SetContentView(Resource.Layout.Activity_To_Do);

            // Initialize the progress bar
			progressBar = FindViewById<ProgressBar>(Resource.Id.loadingProgressBar);
			progressBar.Visibility = ViewStates.Gone;

			// Create ProgressFilter to handle busy state
			// Create ProgressFilter to handle busy state
			var progressHandler = new ProgressHandler ();
			progressHandler.BusyStateChange += (busy) => {
				if (progressBar != null) 
					progressBar.Visibility = busy ? ViewStates.Visible : ViewStates.Gone;
			};

			try 
            {
                // Check to ensure everything's setup right
                PushClient.CheckDevice(this);
                PushClient.CheckManifest(this);

                // Register for push notifications
                System.Diagnostics.Debug.WriteLine("Registering...");
                PushClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS);

				CurrentPlatform.Init ();
				// Create the Mobile Service Client instance, using the provided
				// Mobile Service URL and key
				client = new MobileServiceClient(
					Constants.ApplicationURL,
					Constants.ApplicationKey, progressHandler);

				// Get the Mobile Service Table instance to use
				todoTable = client.GetTable<TodoItem>();

				textNewTodo = FindViewById<EditText>(Resource.Id.textNewTodo);

				// Create an adapter to bind the items with the view
				adapter = new TodoItemAdapter(this, Resource.Layout.Row_List_To_Do);
				var listViewTodo = FindViewById<ListView>(Resource.Id.listViewTodo);
				listViewTodo.Adapter = adapter;

				// Load the items from the Mobile Service
				await RefreshItemsFromTableAsync();

			} 
            catch (Java.Net.MalformedURLException) 
            {
				CreateAndShowDialog(new Exception ("There was an error creating the Mobile Service. Verify the URL"), "Error");
			} 
            catch (Exception e) 
            {
				CreateAndShowDialog(e, "Error");
			}
		}
开发者ID:ARMoir,项目名称:mobile-samples,代码行数:62,代码来源:TodoActivity.cs


示例4: Progress

 /// <summary>
 /// Creates a new progress reporter.
 /// </summary>
 /// <param name="handler">Report through this handler.</param>
 public Progress(ProgressHandler handler)
 {
     this.handler = handler;
       this.fractions = new Stack<double>();
       this.fractions.Push(1d);
       this.value = 0d;
       this.lastProgressSet = 0;
 }
开发者ID:dbrgn,项目名称:pi-vote,代码行数:12,代码来源:ProgressHandler.cs


示例5: OnCreate

        protected override async void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Activity_To_Do);

            progressBar = FindViewById<ProgressBar> (Resource.Id.loadingProgressBar);

            // Initialize the progress bar
            progressBar.Visibility = ViewStates.Gone;

            // Create ProgressFilter to handle busy state
            var progressHandler = new ProgressHandler ();
            progressHandler.BusyStateChange += (busy) => {
                if (progressBar != null) 
                    progressBar.Visibility = busy ? ViewStates.Visible : ViewStates.Gone;
            };

            try {
                CurrentPlatform.Init ();
                // Create the Mobile Service Client instance, using the provided
                // Mobile Service URL and key
                client = new MobileServiceClient (
                    applicationURL,
                    applicationKey, progressHandler);

                string path = 
                    Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "localstore.db");
                
                if (!File.Exists(path))
                {
                    File.Create(path).Dispose();
                }
                var store = new MobileServiceSQLiteStore(path);
                store.DefineTable<ToDoItem>();
                await client.SyncContext.InitializeAsync(store, new SyncHandler(this));

                // Get the Mobile Service Table instance to use
                toDoTable = client.GetSyncTable <ToDoItem> ();

                textNewToDo = FindViewById<EditText> (Resource.Id.textNewToDo);

                // Create an adapter to bind the items with the view
                adapter = new ToDoItemAdapter (this, Resource.Layout.Row_List_To_Do);
                var listViewToDo = FindViewById<ListView> (Resource.Id.listViewToDo);
                listViewToDo.Adapter = adapter;

                // Load the items from the Mobile Service
                await RefreshItemsFromTableAsync ();

            } catch (Java.Net.MalformedURLException) {
                CreateAndShowDialog (new Exception ("There was an error creating the Mobile Service. Verify the URL"), "Error");
            } catch (Exception e) {
                CreateAndShowDialog (e, "Error");
            }
        }
开发者ID:fellipetenorio,项目名称:mobile-services-samples,代码行数:57,代码来源:ToDoActivity.cs


示例6: OnCreate

        private ProgressBar progressBar; // Progress spinner to use for table operations

        // Called when the activity initially gets created
		protected override async void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);

			// Set our view from the "main" layout resource
			SetContentView(Resource.Layout.Activity_To_Do);

            // Initialize the progress bar
			progressBar = FindViewById<ProgressBar>(Resource.Id.loadingProgressBar);
			progressBar.Visibility = ViewStates.Gone;

            // TODO:: Uncomment the following code when using a mobile service
            
			// Create ProgressFilter to handle busy state
			var progressHandler = new ProgressHandler ();
			progressHandler.BusyStateChange += (busy) => {
				if (progressBar != null) 
					progressBar.Visibility = busy ? ViewStates.Visible : ViewStates.Gone;
			};
                     

			try 
            {
                // TODO:: Uncomment the following code to create the mobile services client

				CurrentPlatform.Init ();
				// Create the Mobile Service Client instance, using the provided
				// Mobile Service URL and key
				client = new MobileServiceClient(
					Constants.ApplicationURL,
					Constants.ApplicationKey, progressHandler);

				// Get the Mobile Service Table instance to use
				todoTable = client.GetTable<TodoItem>();

				textNewTodo = FindViewById<EditText>(Resource.Id.textNewTodo);

				// Create an adapter to bind the items with the view
				adapter = new TodoItemAdapter(this, Resource.Layout.Row_List_To_Do);
				var listViewTodo = FindViewById<ListView>(Resource.Id.listViewTodo);
				listViewTodo.Adapter = adapter;

				// Load the items from the Mobile Service
				await RefreshItemsFromTableAsync();

			} 
            catch (Java.Net.MalformedURLException) 
            {
				CreateAndShowDialog(new Exception ("There was an error creating the Mobile Service. Verify the URL"), "Error");
			} 
            catch (Exception e) 
            {
				CreateAndShowDialog(e, "Error");
			}
		}
开发者ID:ARMoir,项目名称:mobile-samples,代码行数:58,代码来源:TodoActivity.cs


示例7: RemoteCallbacks

 internal RemoteCallbacks(
     ProgressHandler onProgress = null,
     TransferProgressHandler onDownloadProgress = null,
     UpdateTipsHandler onUpdateTips = null,
     CredentialsHandler credentialsProvider = null)
 {
     Progress = onProgress;
     DownloadTransferProgress = onDownloadProgress;
     UpdateTips = onUpdateTips;
     CredentialsProvider = credentialsProvider;
 }
开发者ID:nulltoken,项目名称:libgit2sharp,代码行数:11,代码来源:RemoteCallbacks.cs


示例8: OperationPending

        public OperationPending(string langKey, string TaskName, ProgressHandler progressHandler, Cancel cancelCallback = null, bool AutoClose = false)
            : base(langKey)
        {
            InitializeComponent();
            this.progressHandler = progressHandler;
            this.TaskName = TaskName;
            this.CancelCallback = cancelCallback;
            this.AutoClose = AutoClose;

            this.LangKey = langKey;
            Init();
        }
开发者ID:hamada147,项目名称:ModAPI,代码行数:12,代码来源:OperationPending.xaml.cs


示例9: Load

        public static ResultCode Load(ProgressHandler handler)
        {
            currentProgressHandler = handler;
            string gameConfigPath = Configuration.GetPath("GameConfigurations");
            if (gameConfigPath == "")
            {
                Error = ErrorCode.MALFORMED_CONFIGURATION;
                ErrorString = "Couldn't find the game configurations path.";
                Debug.Log("GUIConfiguration", ErrorString, Debug.Type.ERROR);
                return ResultCode.ERROR;
            }

            string gameConfigFile = Path.GetFullPath(gameConfigPath + Path.DirectorySeparatorChar + Configuration.CurrentGame + Path.DirectorySeparatorChar + "GUI.xml");
            if (!File.Exists(gameConfigFile))
            {
                Error = ErrorCode.FILE_NOT_FOUND;
                ErrorString = "Couldn't find the file \"" + gameConfigFile + "\".";
                Debug.Log("GUIConfiguration", ErrorString, Debug.Type.ERROR);
                return ResultCode.ERROR;
            }

            Debug.Log("GUIConfiguration", "Parsing the GUI configuration file \"" + gameConfigFile + "\".");
            try
            {
                XDocument configuration = XDocument.Load(gameConfigFile);
                Tabs = new List<Tab>();
                if (!ParseTabs(configuration.Root))
                {
                    Error = ErrorCode.MALFORMED_CONFIGURATION;
                    ErrorString = "The configuration file \"" + gameConfigFile + "\" contains invalid elements.";
                    Debug.Log("GUIConfiguration", ErrorString, Debug.Type.ERROR);
                    return ResultCode.ERROR;
                }
            }
            catch (System.Xml.XmlException ex)
            {
                Error = ErrorCode.MALFORMED_CONFIGURATION;
                ErrorString = "The file \"" + gameConfigFile + "\" couldn't be parsed. Exception: " + ex.ToString();
                Debug.Log("GUIConfiguration", ErrorString, Debug.Type.ERROR);
                return ResultCode.ERROR;
            }
            catch (Exception ex)
            {
                Error = ErrorCode.MALFORMED_CONFIGURATION;
                ErrorString = "The file \"" + gameConfigFile + "\" couldn't be parsed. Unexpected exception: " + ex.ToString();
                Debug.Log("GUIConfiguration", ErrorString, Debug.Type.ERROR);
                return ResultCode.ERROR;
            }
            Debug.Log("GUIConfiguration", "Successfully parsed the GUI configuration.");
            ChangeProgress(100f);
            return ResultCode.OK;
        }
开发者ID:hamada147,项目名称:ModAPI,代码行数:52,代码来源:GUIConfiguration.cs


示例10: Fetch

 public virtual void Fetch(
     Remote remote,
     TagFetchMode? tagFetchMode = null,
     ProgressHandler onProgress = null,
     UpdateTipsHandler onUpdateTips = null,
     TransferProgressHandler onTransferProgress = null,
     Credentials credentials = null)
 {
     Fetch(remote, new FetchOptions
     {
         TagFetchMode = tagFetchMode,
         OnProgress = onProgress,
         OnUpdateTips = onUpdateTips,
         OnTransferProgress = onTransferProgress,
         Credentials = credentials
     });
 }
开发者ID:kgybels,项目名称:libgit2sharp,代码行数:17,代码来源:Network.cs


示例11: Fetch

        /// <summary>
        /// Fetch from the <see cref="Remote"/>.
        /// </summary>
        /// <param name="remote">The remote to fetch</param>
        /// <param name="tagFetchMode">Optional parameter indicating what tags to download.</param>
        /// <param name="onProgress">Progress callback. Corresponds to libgit2 progress callback.</param>
        /// <param name="onUpdateTips">UpdateTips callback. Corresponds to libgit2 update_tips callback.</param>
        /// <param name="onTransferProgress">Callback method that transfer progress will be reported through.
        /// Reports the client's state regarding the received and processed (bytes, objects) from the server.</param>
        /// <param name="credentials">Credentials to use for username/password authentication.</param>
        public virtual void Fetch(
            Remote remote,
            TagFetchMode? tagFetchMode = null,
            ProgressHandler onProgress = null,
            UpdateTipsHandler onUpdateTips = null,
            TransferProgressHandler onTransferProgress = null,
            Credentials credentials = null)
        {
            Ensure.ArgumentNotNull(remote, "remote");

            using (RemoteSafeHandle remoteHandle = Proxy.git_remote_load(repository.Handle, remote.Name, true))
            {
                var callbacks = new RemoteCallbacks(onProgress, onTransferProgress, onUpdateTips, credentials);
                GitRemoteCallbacks gitCallbacks = callbacks.GenerateCallbacks();

                if (tagFetchMode.HasValue)
                {
                    Proxy.git_remote_set_autotag(remoteHandle, tagFetchMode.Value);
                }

                // It is OK to pass the reference to the GitCallbacks directly here because libgit2 makes a copy of
                // the data in the git_remote_callbacks structure. If, in the future, libgit2 changes its implementation
                // to store a reference to the git_remote_callbacks structure this would introduce a subtle bug
                // where the managed layer could move the git_remote_callbacks to a different location in memory,
                // but libgit2 would still reference the old address.
                //
                // Also, if GitRemoteCallbacks were a class instead of a struct, we would need to guard against
                // GC occuring in between setting the remote callbacks and actual usage in one of the functions afterwords.
                Proxy.git_remote_set_callbacks(remoteHandle, ref gitCallbacks);

                try
                {
                    Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch);
                    Proxy.git_remote_download(remoteHandle);
                    Proxy.git_remote_update_tips(remoteHandle);
                }
                finally
                {
                    Proxy.git_remote_disconnect(remoteHandle);
                }
            }
        }
开发者ID:dahlbyk,项目名称:libgit2sharp,代码行数:52,代码来源:Network.cs


示例12: handleProgress

        private void handleProgress(int i)
        {
            // InvokeRequired required compares the thread ID of the
            // calling thread to the thread ID of the creating thread.
            // If these threads are different, it returns true.
            if (this.InvokeRequired)
            {
                ProgressHandler call = new ProgressHandler(handleProgress);
                this.BeginInvoke(call, new object[] { i });
            }
            else
            {
                if (0 <= i && i <= 100)
                {
                    progressBar1.Value = i;
                    progressBar1.Invalidate();
                }
                else this.Close();

            }
        }
开发者ID:kernrot,项目名称:ThreadedProgressForms,代码行数:21,代码来源:ProgressForm.cs


示例13: Download

    // Virtual solely so that we can subclass for testing, because mocks don't work with delegates.
    public virtual void Download(string pid, AtStartHandler atStart, ProgressHandler progress, AtEndHandler atEnd) {
      var page = GetIphonePage(pid);

      if (!page.IsAvailable) {
        atEnd(DownloadStatus.Unavailable, pid);
        return;
      }

      var finalPath = FilenameSafe(GetTitle(pid)) + page.FileExtension;
      var tempPath  = finalPath + ".partial";

      if (File.Exists(finalPath)){
        atEnd(DownloadStatus.AlreadyExists, finalPath);
        return;
      }

      atStart(finalPath);

      var request       = new CoreMediaRequest(page.EmbeddedMediaUrl, cookies);
      var contentLength = request.ContentLength;
      int totalReceived = 0;

      using (var localStream = new FileStream(tempPath, FileMode.Append, FileAccess.Write, FileShare.Read)) {
        totalReceived = (int)localStream.Position;
        request.GetResponseStreamFromOffset(totalReceived, remoteStream => {
          ReadFromStream(remoteStream, (buffer, bytesRead) => {
            localStream.Write(buffer, 0, bytesRead);
            totalReceived += bytesRead;
            progress(totalReceived, contentLength);
          });
        });
      }

      if (totalReceived >= contentLength) {
        File.Move(tempPath, finalPath);
        atEnd(DownloadStatus.Complete, finalPath);
      } else {
        atEnd(DownloadStatus.Incomplete, tempPath);
      }
    }
开发者ID:threedaymonk,项目名称:iplayer-dl.net,代码行数:41,代码来源:Downloader.cs


示例14: OnCreate

        private ProgressBar progressBar; // Progress spinner to use for table operations

        // Called when the activity initially gets created
		protected override async void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);

			// Set our view from the "main" layout resource
			SetContentView(Resource.Layout.Activity_To_Do);

            // Initialize the progress bar
			progressBar = FindViewById<ProgressBar>(Resource.Id.loadingProgressBar);
			progressBar.Visibility = ViewStates.Gone;

			// Create ProgressFilter to handle busy state
			var progressHandler = new ProgressHandler ();
			progressHandler.BusyStateChange += (busy) => {
				if (progressBar != null) 
					progressBar.Visibility = busy ? ViewStates.Visible : ViewStates.Gone;
			};

			try 
            {
				CurrentPlatform.Init ();
				// Create the Mobile Service Client instance, using the provided
				// Mobile Service URL and key
				client = new MobileServiceClient(
					Constants.ApplicationURL,
					Constants.ApplicationKey, progressHandler);

                await Authenticate();
                await CreateTable();
			} 
            catch (Java.Net.MalformedURLException) 
            {
				CreateAndShowDialog(new Exception ("There was an error creating the Mobile Service. Verify the URL"), "Error");
			} 
            catch (Exception e) 
            {
				CreateAndShowDialog(e, "Error");
			}
		}
开发者ID:ARMoir,项目名称:mobile-samples,代码行数:42,代码来源:TodoActivity.cs


示例15: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.LoginScreen);

            var submitButton = FindViewById<Button>(Resource.Id.BtnLogin);
            var urlInput = FindViewById<EditText>(Resource.Id.LoginScreenServerUrlInput);
            var keyInput = FindViewById<EditText>(Resource.Id.LoginScreenUserKeyInput);

            var login = new Login();
            urlInput.Text = login.Url;
            keyInput.Text = login.Key;

            submitButton.Click += delegate
                {
                    var dialog = ProgressDialog.Show(this, "", "Connecting to server and validating key...", true);
                    var handler = new ProgressHandler(dialog);

                    new Login().ValidateAndStore(urlInput.Text, keyInput.Text, (valid) => RunOnUiThread(() =>
                        {
                            if (valid == Login.ValidationSuccess)
                            {
                                dialog.SetMessage("Successfully connected to " + urlInput.Text);
                                var widgetContainer = new Intent(this, typeof(WidgetContainer));
                                StartActivity(widgetContainer);
                                Finish();
                                handler.SendEmptyMessage(0);
                            } else
                            {
                                dialog.SetMessage("Connection failed. Please try again");
                                handler.SendEmptyMessage(0);
                                NotifyInvalidInput();
                            }
                        }));
                };
        }
开发者ID:Smeedee,项目名称:Smeedee-Mobile,代码行数:36,代码来源:LoginScreen.cs


示例16: Restore_Click

        private void Restore_Click(object sender, RoutedEventArgs e)
        {
            ProgressHandler progressHandler = new ProgressHandler();
            progressHandler.OnComplete += (s, ev) => Dispatcher.Invoke((Action) delegate() {
                Task.Complete();
            });
            Thread t = new Thread(delegate() {
                try
                {
                    string steamPath = Configurations.Configuration.GetPath("Steam");
                    Process p = new Process();
                    p.StartInfo.FileName = steamPath + System.IO.Path.DirectorySeparatorChar + "Steam.exe";
                    p.StartInfo.Arguments = "steam://validate/" + App.Game.GameConfiguration.SteamAppID;
                    p.StartInfo.UseShellExecute = false;
                    p.Start();
                    progressHandler.Task = "Restore";
                    progressHandler.Progress = 50f;
                    int state = 0;
                    string lastLine = "";
                    while (true)
                    {
                        Process[] processes = Process.GetProcesses();
                        bool foundSteam = false;
                        foreach (Process pp in processes)
                        {
                            try
                            {
                                if (!pp.HasExited && pp.ProcessName == "Steam")
                                {
                                    foundSteam = true;
                                    break;
                                }
                            }
                            catch (System.Exception ex)
                            {
                            }
                        }

                        string logFile = steamPath + System.IO.Path.DirectorySeparatorChar + "logs" + System.IO.Path.DirectorySeparatorChar + "content_log.txt";
                        System.IO.FileStream s = new System.IO.FileStream(logFile, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
                        System.IO.FileInfo f = new System.IO.FileInfo(logFile);
                        byte[] data = new byte[f.Length];
                        s.Read(data, 0, (int)f.Length);
                        string content = System.Text.Encoding.UTF8.GetString(data);

                        string[] l = content.Split(new string[] { "\r\n" }, System.StringSplitOptions.None);// System.IO.File.ReadAllLines(SteamPath + "\\logs\\content_log.txt");
                        if (lastLine == "")
                            lastLine = l[l.Length - 2];
                        bool check = false;
                        foreach (string n in l)
                        {
                            if (n == lastLine)
                                check = true;
                            if (check)
                            {
                                if (n.EndsWith("AppID " + App.Game.GameConfiguration.SteamAppID + " state changed : Fully Installed,"))
                                    state = 3;
                                else if (n.Contains("AppID " + App.Game.GameConfiguration.SteamAppID) && n.Contains("(Suspended)"))
                                    state = 1;
                                else if (n.Contains("Failed to get list of download sources from any known CS!"))
                                    state = 2;
                            }
                        }

                        if (state == 0 && !foundSteam)
                        {
                            state = 4;
                        }

                        if (state > 0)
                            break;

                        Thread.Sleep(500);

                    }

                    if (state == 3)
                    {
                        progressHandler.Task = "Finish";
                        progressHandler.Progress = 100f;
                    }
                    else
                    {
                        if (state == 1)
                            progressHandler.Task = "Error.Cancelled";
                        else if (state == 2)
                            progressHandler.Task = "Error.NoConnection";
                        else if (state == 4)
                            progressHandler.Task = "Error.SteamClosed";

                        Dispatcher.Invoke((Action)delegate()
                        {
                            Task.Complete();
                        });
                    }

                }
                catch (Exception exx)
                {
                    System.Console.WriteLine(exx.ToString());
//.........这里部分代码省略.........
开发者ID:hamada147,项目名称:ModAPI,代码行数:101,代码来源:RestoreGameFiles.xaml.cs


示例17: CreateBallot

 /// <summary>
 /// Create a ballot.
 /// </summary>
 /// <remarks>
 /// Used to multi-thread ballot creation.
 /// </remarks>
 /// <param name="input">Parameters needed to create the ballot.</param>
 /// <param name="progressHandler">Handles the progress done.</param>
 /// <returns>A ballot.</returns>
 private static Ballot CreateBallot(Tuple<IEnumerable<int>, VotingParameters, Question, BigInt> input, ProgressHandler progressHandler)
 {
     return new Ballot(input.First, input.Second, input.Third, input.Fourth, new Progress(progressHandler));
 }
开发者ID:dbrgn,项目名称:pi-vote,代码行数:13,代码来源:VoterEntity.cs


示例18: Vote

        /// <summary>
        /// Cast a vote and pack it in an envelope.
        /// </summary>
        /// <param name="votingMaterial">Voting material.</param>
        /// <param name="voterCertificate">Private certificate of this voter.</param>
        /// <param name="vota">List of vota.</param>
        /// <returns>Signed envelope containing the ballot.</returns>
        public Signed<Envelope> Vote(VotingMaterial votingMaterial, Certificate voterCertificate, IEnumerable<IEnumerable<int>> vota, ProgressHandler progressHandler)
        {
            if (votingMaterial == null)
            throw new ArgumentNullException("votingMaterial");

              bool acceptMaterial = SetVotingMaterial(votingMaterial);

              if (vota == null)
            throw new ArgumentNullException("vota");
              if (vota.Count() != this.parameters.Questions.Count())
            throw new ArgumentException("Bad vota count.");

              if (acceptMaterial)
              {
            List<Tuple<IEnumerable<int>, VotingParameters, Question, BigInt>> inputs = new List<Tuple<IEnumerable<int>, VotingParameters, Question, BigInt>>();

            for (int questionIndex = 0; questionIndex < this.parameters.Questions.Count(); questionIndex++)
            {
              IEnumerable<int> questionVota = vota.ElementAt(questionIndex);
              Question question = this.parameters.Questions.ElementAt(questionIndex);

              if (questionVota == null)
            throw new ArgumentNullException("questionVota");
              if (questionVota.Count() != question.Options.Count())
            throw new ArgumentException("Bad vota count.");
              if (!questionVota.All(votum => votum.InRange(0, 1)))
            throw new ArgumentException("Votum out of range.");

              inputs.Add(new Tuple<IEnumerable<int>, VotingParameters, Question, BigInt>(questionVota, this.parameters, question, this.publicKey));
            }

            List<Ballot> ballots = Parallel
              .Work<Tuple<IEnumerable<int>, VotingParameters, Question, BigInt>, Ballot>(CreateBallot, inputs, progressHandler);

            Envelope ballotContainer = new Envelope(this.parameters.VotingId, voterCertificate.Id, ballots);

            return new Signed<Envelope>(ballotContainer, voterCertificate);
              }
              else
              {
            return null;
              }
        }
开发者ID:dbrgn,项目名称:pi-vote,代码行数:50,代码来源:VoterEntity.cs


示例19: Copy

 public static void Copy(Stream source, Stream destination, byte[] buffer, ProgressHandler progressHandler, TimeSpan updateInterval, object sender, string name, long fixedTarget)
 {
     if (source == null)
     {
         throw new ArgumentNullException("source");
     }
     if (destination == null)
     {
         throw new ArgumentNullException("destination");
     }
     if (buffer == null)
     {
         throw new ArgumentNullException("buffer");
     }
     if (buffer.Length < 0x80)
     {
         throw new ArgumentException("Buffer is too small", "buffer");
     }
     if (progressHandler == null)
     {
         throw new ArgumentNullException("progressHandler");
     }
     bool continueRunning = true;
     DateTime now = DateTime.Now;
     long processed = 0L;
     long target = 0L;
     if (fixedTarget >= 0L)
     {
         target = fixedTarget;
     }
     else if (source.CanSeek)
     {
         target = source.Length - source.Position;
     }
     ProgressEventArgs e = new ProgressEventArgs(name, processed, target);
     progressHandler(sender, e);
     bool flag2 = true;
     while (continueRunning)
     {
         int count = source.Read(buffer, 0, buffer.Length);
         if (count > 0)
         {
             processed += count;
             flag2 = false;
             destination.Write(buffer, 0, count);
         }
         else
         {
             destination.Flush();
             continueRunning = false;
         }
         if ((DateTime.Now - now) > updateInterval)
         {
             flag2 = true;
             now = DateTime.Now;
             e = new ProgressEventArgs(name, processed, target);
             progressHandler(sender, e);
             continueRunning = e.ContinueRunning;
         }
     }
     if (!flag2)
     {
         e = new ProgressEventArgs(name, processed, target);
         progressHandler(sender, e);
     }
 }
开发者ID:RainsSoft,项目名称:sharpcompress,代码行数:66,代码来源:StreamUtils.cs


示例20: SetProgressHandler


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ProgressIndicator类代码示例发布时间:2022-05-24
下一篇:
C# ProgressEventArgs类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap