Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class ServiceClient
- {
- public ServiceClient(string address, int port) { }
- public IEnumerable<string>ProcessRequests( IEnumerable<string> next )
- {
- foreach (var req in next)
- {
- yield return req + " Done";
- }
- }
- }
- class Program
- {
- private static System.Object lockThis = new System.Object();
- static IEnumerable<string> GenerateRequest()
- {
- for (int i = 0; i < 20; i++)
- {
- yield return string.Format("get_user({0})", i);
- }
- }
- static void Main(string[] args)
- {
- var client = new ServiceClient("", 0);
- Parallel.ForEach( client.ProcessRequests( GenerateRequest() ),
- (x) => System.Console.WriteLine(x)
- );
- }
- }
- }
Add Comment
Please, Sign In to add comment