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


C# Job.GetAsync方法代码示例

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


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

示例1: GetJobAsync

 /// <summary>
 /// Asynchronously retrieves information about a search job.
 /// </summary>
 /// <param name="searchId">
 /// ID of a search job.
 /// </param>
 /// <remarks>
 /// This method uses the <a href="http://goo.gl/SFqSPI">GET 
 /// search/jobs/{search_id}</a> endpoint to get the <see cref="Job"/> 
 /// identified by identified by <see cref="searchId"/>.
 /// </remarks>
 public async Task<Job> GetJobAsync(string searchId)
 {
     var resource = new Job(this.Context, this.Namespace, searchId);
     await resource.GetAsync();
     return resource;
 }
开发者ID:paulcbetts,项目名称:splunk-sdk-csharp-pcl,代码行数:17,代码来源:Service.cs

示例2: CreateJobAsync

        /// <summary>
        /// Asynchronously starts a new search <see cref="Job"/>.
        /// </summary>
        /// <param name="args">
        /// Specification of a search job.
        /// </param>
        /// <returns>
        /// An object representing the search job that was started.
        /// </returns>
        /// <remarks>
        /// This method uses the <a href="http://goo.gl/JZcPEb">POST 
        /// search/jobs</a> endpoint to start a new search <see cref="Job"/> as
        /// specified by <see cref="args"/>.
        /// </remarks>
        public async Task<Job> CreateJobAsync(JobArgs args)
        {
            Contract.Requires<ArgumentNullException>(args != null, "args");
            Contract.Requires<ArgumentNullException>(args.Search != null, "args.Search");
            Contract.Requires<ArgumentException>(args.ExecutionMode != ExecutionMode.Oneshot, "args.ExecutionMode: ExecutionMode.Oneshot");

            // FJR: Also check that it's not export, which also won't return a job.
            // DSN: JobArgs does not include SearchExportArgs

            string searchId;

            using (var response = await this.Context.PostAsync(this.Namespace, JobCollection.ClassResourceName, args))
            {
                await response.EnsureStatusCodeAsync(HttpStatusCode.Created);
                searchId = await response.XmlReader.ReadResponseElementAsync("sid");
            }

            // FJR: Jobs need to be handled a little more delicately. Let's talk about the patterns here.
            // In the other SDKs, we've been doing functions to wait for ready and for done. Async means
            // that we can probably make that a little slicker, but let's talk about how.

            Job job = new Job(this.Context, this.Namespace, name: searchId);
            await job.GetAsync();

            return job;
        }
开发者ID:paulcbetts,项目名称:splunk-sdk-csharp-pcl,代码行数:40,代码来源:Service.cs

示例3: Wait

        /// <summary>
        /// Wait for the given job to complete
        /// </summary>
        /// <param name="job">The job</param>
        /// <returns>The same job</returns>
        public Job Wait(Job job)
        {
            while (!job.IsDone)
            {
                Thread.Sleep(1000);
                job.GetAsync().Wait();

            }

            return job;
        }
开发者ID:paulcbetts,项目名称:splunk-sdk-csharp-pcl,代码行数:16,代码来源:TestHelper.cs


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