当前位置: 首页>>代码示例>>C#>>正文


C# ProgressBar.Dispose方法代码示例

本文整理汇总了C#中ProgressBar.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# ProgressBar.Dispose方法的具体用法?C# ProgressBar.Dispose怎么用?C# ProgressBar.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProgressBar的用法示例。


在下文中一共展示了ProgressBar.Dispose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PutObjects

            public void PutObjects()
            {
                var dirs = Directory.GetDirectories(rootPath);

                foreach(var dir in dirs)
                {
                    var files = Directory.GetFiles(dir);

                    foreach(var file in files)
                    {
                        uploadBag.Add(new UploadObject
                        {
                            Container = new DirectoryInfo(dir).Name,
                            Object = PathEscaper.Unescape(Path.GetFileName(file)),
                            Path = file
                        });
                    }
                }

                if (uploadBag.Any())
                {
                    Console.Write("Importing... ");

                    var objCount = uploadBag.Count;

                    var progress = new ProgressBar();

                    Parallel.For(0, objCount - 1, new ParallelOptions { MaxDegreeOfParallelism = 10 },
                      i =>
                      {
                          var uploadObj = uploadBag.ElementAt(i);

                          try
                          {
                              var response = ImportObject(uploadObj).Result;

                              Interlocked.Increment(ref counter);

                              if (!response.IsSuccess)
                              {
                                  ManageFailed(new FailedObject
                                  {
                                      Container = uploadObj.Container,
                                      Message = response.Message,
                                      Object = uploadObj
                                  });
                              }
                          }
                          catch (Exception ex)
                          {
                              ManageFailed(new FailedObject
                              {
                                  Container = uploadObj.Container,
                                  Message = ex.Message,
                                  Object = uploadObj
                              });
                          }

                          progress.Report((double)counter / objCount);
                      });

                    progress.Report(1);
                    progress.Dispose();
                    Console.WriteLine(" Done.");
                }
            }
开发者ID:vtfuture,项目名称:SwiftClient,代码行数:66,代码来源:ImportCommand.cs

示例2: ExportAll

            private void ExportAll(List<SwiftContainerModel> containers, string path, Dictionary<string, string> queryParams = null)
            {
                foreach (var container in containers)
                {
                    listQueue.Enqueue(new ContainerRequest
                    {
                        Container = container.Container,
                        Query = queryParams
                    });
                }

                while (!listQueue.IsEmpty)
                {
                    ContainerRequest request = null;

                    if (listQueue.TryDequeue(out request))
                    {
                        var containerData = client.GetContainer(request.Container, null, request.Query).Result;
                        if (containerData.IsSuccess)
                        {
                            if (containerData.Objects.Count > 0)
                            {
                                if (containerData.Objects.Count < containerData.ObjectsCount)
                                {
                                    var marker = containerData.Objects.OrderByDescending(x => x.Object).Select(x => x.Object).FirstOrDefault();

                                    var newRequest = new ContainerRequest()
                                    {
                                        Container = request.Container,
                                        Query = request.Query
                                    };

                                    if (newRequest.Query == null)
                                    {
                                        newRequest.Query = new Dictionary<string, string>();
                                    }

                                    newRequest.Query["marker"] = marker;

                                    listQueue.Enqueue(newRequest);
                                }

                                var target = Path.Combine(path, request.Container);

                                if (!Directory.Exists(target))
                                {
                                    Directory.CreateDirectory(target);
                                }

                                EnqueueObjects(request.Container, containerData.Objects, target);
                            }
                            
                        }
                    }
                }

                if (downloadBag.Any())
                {
                    Console.Write("Exporting... ");

                    var objCount = downloadBag.Count;

                    var progress = new ProgressBar();

                    Parallel.For(0, objCount - 1, new ParallelOptions { MaxDegreeOfParallelism = 10 },
                      i =>
                      {
                          var downloadObj = downloadBag.ElementAt(i);

                          try
                          {
                              var response = ExportObject(downloadObj).Result;

                              Interlocked.Increment(ref counter);

                              if (!response.IsSuccess)
                              {
                                  ManageFailed(new FailedObject
                                  {
                                      Container = downloadObj.Container,
                                      Message = response.Message,
                                      Object = downloadObj.Object
                                  });
                              }
                          }
                          catch (Exception ex)
                          {
                              ManageFailed(new FailedObject
                              {
                                  Container = downloadObj.Container,
                                  Message = ex.Message,
                                  Object = downloadObj.Object
                              });
                          }

                          progress.Report((double)counter / objCount);
                      });

                    progress.Report(1);
                    progress.Dispose();
//.........这里部分代码省略.........
开发者ID:vtfuture,项目名称:SwiftClient,代码行数:101,代码来源:ExportCommand.cs

示例3: loginButtonClicked

        /// <summary>
        /// Login using credidentials specified in the text fields.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        private void loginButtonClicked(object sender, EventArgs e)
        {
            //Finds the views from the layout
            var loginButton = FindViewById<Button>(Resource.Id.buttonLogin);
            var username = FindViewById<EditText>(Resource.Id.editUsername);
            var password = FindViewById<EditText>(Resource.Id.editPassword);

            // Prevents the user from clicking the login button after being clicked, while communicating with the server.
            loginButton.Clickable = false;

            // Debug only, allows for easy login on the server if no input is given.
            #if DEBUG
            if (String.IsNullOrEmpty(username.Text) && String.IsNullOrEmpty(password.Text))
            {
                username.Text = "test";
                password.Text = "Test123%";
            }
            #endif

            //Tries to login if strings are present in the fields
            if (username.Text != "" || password.Text != "")
            {
                bool loggedIn = false;

                //Adds a spinner to indicate loading
                ProgressBar pb = new ProgressBar(this);
                LinearLayout layout = FindViewById<LinearLayout>(Resource.Id.loginLinear);
                layout.AddView(pb);

                //Does server communication on separate thread to avoid UI-freeze
                ThreadPool.QueueUserWorkItem(o =>
                    {
                        if (Looper.MyLooper() == null)
                            Looper.Prepare();

                        loggedIn = CIF.Login(username.Text, password.Text);

                        //Moves on to next activity, if login is succesful
                        if (loggedIn)
                        {
                            CIF.GetInformation();
                            Intent toProfile = new Intent(this, typeof(ProfileActivity));
                            StartActivity(toProfile);
                        }
                        //Shows an error-messaage, if login was not succesful
                        else
                        {
                            var loginFailedDialog = new Android.Support.V7.App.AlertDialog.Builder(this);
                            loginFailedDialog.SetMessage(CIF.LatestError);
                            loginFailedDialog.SetNegativeButton(Resource.String.ok, (s, earg) =>
                                {
                                });
                            RunOnUiThread(() =>
                                {
                                    loginFailedDialog.Show();
                                });
                        }

                        //Removes the spinner again
                        RunOnUiThread(() =>
                            {
                                layout.RemoveView(pb);
                                pb.Dispose();
                            });

                        loginButton.Clickable = true;
                    });
            }
            //Displays an errormessage, if no username or password is entered
            else
            {
                var noTextAlert = new Android.Support.V7.App.AlertDialog.Builder(this);
                noTextAlert.SetMessage(Resources.GetString(Resource.String.message_empty_username_password));
                noTextAlert.SetNegativeButton(Resource.String.ok, (s, earg) =>
                    {
                    });
                noTextAlert.Show();

                loginButton.Clickable = true;
            }
        }
开发者ID:prozum,项目名称:solitude,代码行数:86,代码来源:MainActivity.cs


注:本文中的ProgressBar.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。