Пример #1
0
        public void Export(AsyncTaskService taskService, string id, string filter, string optin = "All", string group = "All")
        {
            // get people
            if (taskService.UpdateTask(id, "Getting people...", 0) == null)
            {
                return;
            }

            var people = GetPeople(filter, 0, 0, optin, group);

            // zip it
            int i     = 0;
            int total = people.Count();

            taskService.Write(id, "Exporting people...", CalcPct(i, total), GetCSVHeader() + "\n");

            foreach (var person in people)
            {
                taskService.Write(id, "Exporting people...", CalcPct(i, total), person.ToString() + "\n");
                i++;
            }

            taskService.UpdateTask(id, "Ready for download", 100);
            taskService.FinishTask(id);
        }
Пример #2
0
        public void CallTask_wait_done()
        {
            var address = @"net.pipe://127.0.0.1/" + this.GetType().Name + "_" + MethodBase.GetCurrentMethod().Name;
            var binding = new NetNamedPipeBinding();

            var srv = new AsyncTaskService();

            using (var host = new ServiceHost(srv, new Uri(address)))
            {
                host.AddServiceEndpoint(typeof(IAsyncTaskService), binding, address);
                host.Open();

                var done = Task.Factory.StartNew(()=>
                    {
                        using (var factory = new ChannelFactory<IAsyncTaskService>( binding))
                        {
                            var client = factory.CreateChannel(new EndpointAddress(address));
                            var result = client.GetMessages("123");
                            result.Wait();
                            Assert.AreEqual(result.Result, "321");
                        }
                    });
                done.Wait();
            }
        }