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


C# Action.Invoke方法代码示例

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


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

示例1: AppUpdateControl

        public AppUpdateControl(IEnumerable<IAppVersion> appVersions, Action<IAppVersion> updateAction)
        {
            this.NewestVersion = appVersions.First();
            InitializeComponent();

            this.AppIconImage.ImageFailed += (sender, e) => { this.AppIconImage.Source = new BitmapImage(new Uri("/Assets/windows_phone.png", UriKind.RelativeOrAbsolute)); };
            this.AppIconImage.Source = new BitmapImage(new Uri(HockeyClient.Current.AsInternal().ApiBaseVersion2 + "apps/" + NewestVersion.PublicIdentifier + ".png"));

            this.ReleaseNotesBrowser.Opacity = 0;
            this.ReleaseNotesBrowser.Navigated += (sender, e) => { (this.ReleaseNotesBrowser.Resources["fadeIn"] as Storyboard).Begin(); };
            this.ReleaseNotesBrowser.NavigateToString(WebBrowserHelper.WrapContent(NewestVersion.Notes));
            this.ReleaseNotesBrowser.Navigating += (sender, e) =>
            {
                e.Cancel = true;
                WebBrowserTask browserTask = new WebBrowserTask();
                browserTask.Uri = e.Uri;
                browserTask.Show();
            };
            this.InstallAETX.Click += (sender, e) =>
            {
                WebBrowserTask webBrowserTask = new WebBrowserTask();
                webBrowserTask.Uri = new Uri(HockeyClient.Current.AsInternal().ApiBaseVersion2 + "apps/" + NewestVersion.PublicIdentifier + ".aetx", UriKind.Absolute);
                webBrowserTask.Show();
            };
            this.InstallOverApi.Click += (sender, e) => {
                this.Overlay.Visibility = Visibility.Visible;
                updateAction.Invoke(NewestVersion); 
            };
            
        }
开发者ID:bitstadium,项目名称:HockeySDK-Windows,代码行数:30,代码来源:AppUpdateControl.xaml.cs

示例2: DownloadAsync

        public static void DownloadAsync(string url, Action<WebException, WebAlbum> callback)
        {
            var request = WebRequest.Create(new Uri(url));
            _currentRequests.Add(request);

            request.BeginGetResponse(ar =>
            {
                var currrentRequests = (List<WebRequest>)ar.AsyncState;

                try
                {
                    using (var response = request.EndGetResponse(ar))
                    {
                        var reader = XmlReader.Create(response.GetResponseStream());
                        callback.Invoke(null, GetAlbumDetails(reader));
                    }
                }
                catch (WebException ex)
                {
                    callback.Invoke(ex, null);
                }
                catch (IOException ex)
                {
                    //callback.Invoke(ex, null);
                    //TODO: log web response fail (usually after abort)
                }
                finally
                {
                    currrentRequests.Remove(request);
                }
            }, _currentRequests);
        }
开发者ID:leetreveil,项目名称:Zune-Social-Tagger,代码行数:32,代码来源:AlbumDetailsDownloader.cs

示例3: UploadFiles

        public static JsonResult UploadFiles(this Controller controller, Action<UploadedFile> action)
        {
            if (controller.Request.IsAjaxRequest())
            {
                try
                {
                    action.Invoke(new UploadedFile(
                        controller.Server.UrlDecode(controller.Request.Headers["x-file-name"]),
                        controller.Request.InputStream
                    ));
                    return new JsonResult { Data = new { success = true } };
                }
                catch (IOException ex)
                {
                    return new JsonResult { Data = new { success = false, error = ex.Message } };
                }
            }
            else
            {
                try
                {
                    foreach (var key in controller.Request.Files.AllKeys)
                    {
                        var file = controller.Request.Files[key];
                        action.Invoke(new UploadedFile(file.FileName, file.InputStream));
                    }

                    return new JsonResult { Data = new { success = true }, ContentType = "text/html" }; // IE fix
                }
                catch (IOException ex)
                {
                    return new JsonResult { Data = new { success = false, error = ex.Message }, ContentType = "text/html" }; // IE fix
                }
            }
        }
开发者ID:Myslik,项目名称:opencat,代码行数:35,代码来源:ControllerExtensions.cs

示例4: Display

		public bool Display (string body, string cancelButtonTitle, string acceptButtonTitle = "", Action action = null, bool negativeAction = false)
		{
			AlertDialog.Builder alert = new AlertDialog.Builder (Forms.Context);

			alert.SetTitle ("Alert");
			alert.SetMessage (body);
			alert.SetNeutralButton (cancelButtonTitle, (senderAlert, args) => {

			});


			if (acceptButtonTitle != "") {
				if (!negativeAction) {
					alert.SetPositiveButton (acceptButtonTitle, (senderAlert, args) => {
						if (action != null) {
							action.Invoke ();
						}
					});
				} else {
					alert.SetNegativeButton (acceptButtonTitle, (senderAlert, args) => {
						if (action != null) {
							action.Invoke ();
						}
					});
				}
			}

			((Activity)Forms.Context).RunOnUiThread (() => {
				alert.Show ();
			});
			return true;
		}
开发者ID:MobileFit,项目名称:CoachV2,代码行数:32,代码来源:CustomDialogService.cs

示例5: DisplayMessageUsingAction

 public void DisplayMessageUsingAction(Action<string> printMessageAction)
 {
     ConversionFunction = GetIdAsString;
     printMessageAction.Invoke(Name);
     printMessageAction.Invoke(Address);
     printMessageAction.Invoke(ConversionFunction.Invoke(Id));
 }
开发者ID:ananth039,项目名称:Anantha-Kumar-.net-Practice-programs,代码行数:7,代码来源:Student.cs

示例6: WrapTransaction

 /// <summary>
 /// Wraps code in a BeginTransaction and CommitTransaction
 /// </summary>
 /// <param name="action">The action.</param>
 public void WrapTransaction( Action action )
 {
     if ( !_transactionInProgress )
     {
         _transactionInProgress = true;
         using ( var dbContextTransaction = this.Database.BeginTransaction() )
         {
             try
             {
                 action.Invoke();
                 dbContextTransaction.Commit();
             }
             catch ( Exception ex )
             {
                 dbContextTransaction.Rollback();
                 throw ( ex );
             }
             finally
             {
                 _transactionInProgress = false;
             }
         }
     }
     else
     {
         action.Invoke();
     }
 }
开发者ID:Ganon11,项目名称:Rock,代码行数:32,代码来源:DbContext.cs

示例7: DeleteFile

        public void DeleteFile(string fileName, Action<bool> completed = null)
        {
            try {

                string imagename = fileName.Replace (".pdf", ".jpeg").Replace (".mp4", ".jpeg");

                var documents = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
                var directoryname = Path.Combine (documents, "Downloads");
                if (Directory.Exists (directoryname)) {
                    foreach (var file in Directory.GetFiles(directoryname)) {
                        var item = file.Substring (file.LastIndexOf ("/") + 1, file.Length - 1 - file.LastIndexOf ("/"));
                        if (item == fileName || item == imagename) {
                            File.Delete (file);
                        }
                    }
                }
                //File.Delete (fileItem.FilePath.Replace("file://",""));
                //File.Delete (fileItem.ThumbPath.Replace("file://",""));
                completed.Invoke (true);
            } catch {

                completed.Invoke (false);
                throw;
            }
        }
开发者ID:CorningWebServices,项目名称:SolutionsKiosk,代码行数:25,代码来源:DeleteService.cs

示例8: GetRealVideoAddress

        public static async Task<string> GetRealVideoAddress(string url, Action<Error> onFail = null)
        {
            string address = string.Empty;

            DataLoader loader = new DataLoader();
            await loader.LoadDataAsync(url, response => {
                RealVideoAddressData data = JsonSerializer.Deserialize<RealVideoAddressData>(response, true);
                if(data.Status.Equals("ok", StringComparison.OrdinalIgnoreCase))
                {
                    address = data.Info;
                }
                else
                {
                    if(onFail != null)
                    {
                        onFail.Invoke(new Error() { Message = data.Info });
                    }
                }
            }, error => {
                if(onFail != null)
                {
                    onFail.Invoke(error);
                }
            });

            return address;
        }
开发者ID:Yardley999,项目名称:MGTV,代码行数:27,代码来源:VideoAPI.cs

示例9: UsingShared

		/// <summary>
		/// perform an Action while using a shared lock on main thread.
		/// </summary>
		/// <param name="safeAction">Action to perform</param>
		public static void UsingShared(Action unsafeAction)
		{
			if (ThreadTracker.IsGameThread)
				unsafeAction.Invoke();
			else
				using (Lock_MainThread.AcquireSharedUsing())
					unsafeAction.Invoke();
		}
开发者ID:helppass,项目名称:Autopilot,代码行数:12,代码来源:MainLock.cs

示例10: BuildFromDatasource

 void BuildFromDatasource(DataSourcePropertyAttribute dataSourcePropertyAttribute, Action<IEnumerable<string>, bool> itemsCalculated) {
     CompositeView compositeView = _propertyEditor.View;
     if (compositeView!=null) {
         compositeView.ObjectSpace.ObjectChanged += (sender, args) => {
             var comboBoxItems = GetComboBoxItems(dataSourcePropertyAttribute);
             itemsCalculated.Invoke(comboBoxItems,true);
         };
         itemsCalculated.Invoke(GetComboBoxItems(dataSourcePropertyAttribute),false);
     }
 }
开发者ID:testexpand,项目名称:eXpand,代码行数:10,代码来源:ComboBoxItemsBuilder.cs

示例11: Enqueue

 /// <summary>
 /// Enqueues another action without considering the cancellation token.
 /// </summary>
 /// <param name="loop">The loop to extend.</param>
 /// <param name="action">The action to enqueue.</param>
 /// <param name="priority">The priority of the item.</param>
 public static void Enqueue(this IEventLoop loop, Action action, TaskPriority priority = TaskPriority.Normal)
 {
     if (loop != null)
     {
         loop.Enqueue(c => action.Invoke(), priority);
     }
     else
     {
         action.Invoke();
     }
 }
开发者ID:Wojdav,项目名称:AngleSharp,代码行数:17,代码来源:EventLoopExtensions.cs

示例12: Grid_Loaded

        private void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            try{
            ImageSourceConverter isc = new ImageSourceConverter();
            string strDir = @"C:\ProgramData\MyIPWebcamTimeLapse\MyIPWebcamTimeLapse\1.0.0.4\192.168.1.13\20130311\";
            Action act = new Action(() =>
            {
                try
                {
                    foreach (string fil in System.IO.Directory.EnumerateFiles(strDir))
                    {
                        if (!liss.ContainsKey(fil))
                        {
                            ImageSource iss = isc.ConvertFromString(fil) as ImageSource;
                            liss.Add(fil, iss);
                        }
                    }
                }
                catch (Exception ec)
                {
                    string sdsldkfjsldkjf = ec.Message;
                }
            });
            act.Invoke();
            int i = 0; 
            TimerCallback tc = new TimerCallback((a) => {

                act.Invoke();
                try
                {
                    SetImageCallback d = new SetImageCallback((ims,_i)=>{                            
                        image1.Source = ims;
                        this.Title =_i+"."+ System.DateTime.Now.ToString("HH:mm:ss");
                    });

                    this.Dispatcher.Invoke(d,liss.Select(x => x.Value).ToArray()[i],i);
                }
                catch (Exception ex)
                {
                    string s = ex.Message;
                }
                i++;

                if(i == liss.Count)
                    i=1;
                    
            });
            System.Threading.Timer tim = new Timer(tc,null,0,50);
            }
            catch (Exception ec)
            {
                string sdsldkfjsldkjf = ec.Message;
            }
        }
开发者ID:Hagser,项目名称:csharp,代码行数:54,代码来源:MainWindow.xaml.cs

示例13: ThreadSafeInvoke

 public static void ThreadSafeInvoke(DispatcherPriority priority, Action action)
 {
     if (Application.Current.Dispatcher.CheckAccess())
     {
         action.Invoke();
     }
     else
     {
         Application.Current.Dispatcher.Invoke(priority, new Action(delegate()
         {
             action.Invoke();
         }));
     }
 }
开发者ID:kkalinowski,项目名称:lib12,代码行数:14,代码来源:WpfUtilities.cs

示例14: DeleteAllMedia

 public void DeleteAllMedia(Action<bool> completed = null)
 {
     try {
         var documents = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
         var directoryname = Path.Combine (documents, "Downloads");
         if (Directory.Exists (directoryname)) {
             foreach (var file in Directory.GetFiles(directoryname)) {
                 File.Delete (file);
             }
         }
         completed.Invoke (true);
     } catch (Exception ex) {
         completed.Invoke (false);
     }
 }
开发者ID:CorningWebServices,项目名称:SolutionsKiosk,代码行数:15,代码来源:DeleteService.cs

示例15: HandleError

        internal static bool HandleError(JObject json, Action<int> error)
        {
            if (json == null)
            {
                error.Invoke(6); // Illegal Response
                return true;
            }
            if (json["error"] != null)
            {
                error.Invoke(json["error"].Value<int>(0));
                return true;
            }

            return false;
        }
开发者ID:kamaelyoung,项目名称:WPPMM,代码行数:15,代码来源:BasicResultHandler.cs


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