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


C# Service.LogoffAsync方法代码示例

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


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

示例1: SearchRealTime

        /// <summary>
        /// Do real time seach
        /// </summary>
        /// <param name="service">The service.</param>
        /// <returns></returns>
        static async Task SearchRealTime(Service service)
        {

            await service.LoginAsync("admin", "changeme");

            // Realtime window is 5 minutes
            var jobArgs = new JobArgs("search index=_internal")
            {
                SearchMode = SearchMode.Realtime,
                EarliestTime = "rt-5m",
                LatestTime = "rt",
            };

            Job job = await service.CreateJobAsync(jobArgs);


            //this sleep should be removed if DVPL-4503 is fixed.
            //Thread.Sleep(5000);
            for (var i = 0; i < 5; i++)
            {
                System.Console.WriteLine("============================= Snapshot {0}=================================", i);

                using (SearchResults searchResults = await job.GetSearchResultsPreviewAsync())
                {
                    System.Diagnostics.Debug.Assert(!searchResults.AreFinal);
                    System.Console.WriteLine("searchResults count:{0}", searchResults.Count());

                }

                Thread.Sleep(1000);
            }

            await job.CancelAsync();

            await service.LogoffAsync();
        }
开发者ID:paulcbetts,项目名称:splunk-sdk-csharp-pcl,代码行数:41,代码来源:Program.cs

示例2: OneshotSearch

        /// <summary>
        /// Called when [search].
        /// </summary>
        /// <param name="service">The service.</param>
        /// <returns></returns>
        static async Task OneshotSearch(Service service)
        {
            //// Login
            await service.LoginAsync("admin", "changeme");

            // Simple oneshot search
            using (SearchResults searchResults = await service.SearchOneshotAsync("search index=_internal | head 5"))
            {
                foreach (Result record in searchResults)
                {
                    Console.WriteLine(record);
                }
            }

            //Use JobArgs to define the search
            JobArgs args = new JobArgs("search index=_internal | head 5")
            {
                AutoCancel = 0,
            };

            using (SearchResults searchResults = await service.SearchOneshotAsync(args))
            {
                foreach (Result record in searchResults)
                {
                    Console.WriteLine(record);
                }
            }

            await service.LogoffAsync();
        }
开发者ID:paulcbetts,项目名称:splunk-sdk-csharp-pcl,代码行数:35,代码来源:Program.cs


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