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


C# Group.Reply方法代码示例

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


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

示例1: Main

 static void Main(string[] args)
 {
     IsisSystem.Start();
     Group g = new Group("foo");
     int myRank = 0;
     g.ViewHandlers += (ViewHandler)delegate(View v)
     {
         IsisSystem.WriteLine("New View: " + v);
         myRank = v.GetMyRank();
         if (v.members.Length == 3)
             go.Release(1);
     };
     g.Handlers[UPDATE] += (Action<int, int>)delegate(int rank, int n)
     {
         database.Add(new tuple(n, rank));
         IsisSystem.WriteLine("[" + database.Count() + "]  New tuple: " + rank + "/" + n);
         if (database.Count() == 15)
             dbFull.Release(1);
     };
     g.Handlers[LOOKUP] += (Action<int>)delegate(int arg)
     {
         IsisSystem.WriteLine("=== Query for arg=" + arg);
         List<int> answer = new List<int>();
         int index = 0;
         foreach (tuple tp in database)
             if (index++ % 3 == myRank)
             {
                 IsisSystem.WriteLine("Looking at " + tp.rank + "/" + tp.value);
                 if (tp.rank == arg)
                 {
                     IsisSystem.WriteLine("Including " + tp.rank + "/" + tp.value);
                     answer.Add(tp.value);
                 }
             }
         g.Reply(answer);
     };
     g.Join();
     go.WaitOne();
     for (int n = 0; n < 5; n++)
         g.OrderedSend(UPDATE, myRank, n);
     IsisSystem.WriteLine("Wait until database is full!");
     dbFull.WaitOne();
     IsisSystem.WriteLine("Database is fully populated!");
     if (myRank == 1)
         for (int n = 0; n < 3; n++)
         {
             List<List<int>> results = new List<List<int>>();
             g.OrderedQuery(Group.ALL, LOOKUP, n, new Isis.EOLMarker(), results);
             IsisSystem.WriteLine("\r\nAnswers for Query rank=" + n);
             foreach (List<int> list in results)
                 foreach (int value in list)
                     IsisSystem.Write(value + " ");
         }
     IsisSystem.WaitForever();
 }
开发者ID:jhc247,项目名称:CS5412-Smartcar,代码行数:55,代码来源:Program.cs

示例2: Main

        static void Main(string[] args)
        {
            IsisSystem.Start();
            Group g = new Group("automobile");

            Semaphore sem = new Semaphore(0, 20);
            Semaphore timeSem = new Semaphore(0, 1);

            //view handler
            g.ViewHandlers += (ViewHandler)delegate(View v)
            {
                view = v;
                Console.WriteLine("Auto View" + v);
                Console.Title = "View=" + v.viewid + "Rank=" + v.GetMyRank();
                myRank = v.GetMyRank();
                if (v.members.Length == 1)
                {
                    sem.Release();
                }

            };

            //SET handler
            g.Handlers[SET] += (Action<string, List<string>>)delegate(string entityName, List<string> attributes)
            {
                //               Console.WriteLine("entering into SET");
                lock (autoEntity)
                {

                    string[] attr;
                    if (!autoEntity.ContainsKey(entityName))
                    {
                        //                     Console.WriteLine("adding new entity in Dictionary");
                        autoEntity.Add(entityName, new Dictionary<string, string>());
                    }
                    // else
                    {

                        foreach (string s in attributes)
                        {
                            attr = s.Split(new char[] { '=' });

                            if (attr[1].Equals("null"))
                            {
                                //                           Console.WriteLine("Removing entries for attribute value=null");
                                autoEntity[entityName].Remove(attr[0]);
                            }
                            else if (!autoEntity[entityName].ContainsKey(attr[0]))
                            {
                                autoEntity[entityName].Add(attr[0], attr[1]);
                            }
                            else
                            {
                                autoEntity[entityName][attr[0]] = attr[1];
                            }
                        }

                    }

                }
            };

            //GET handler- for ordered query
            g.Handlers[GET] += (Action<string, List<string>>)delegate(string entityName, List<string> attributes)
            {
                List<KeyValuePair<string, string>> getList = new List<KeyValuePair<string, string>>();
                Console.WriteLine("entering into GET");
                if (autoEntity.ContainsKey(entityName))
                {
                    foreach (string a in attributes)
                    {
                        if (autoEntity[entityName].ContainsKey(a))
                        {
                            getList.Add(autoEntity[entityName].ElementAt(0));
                        }
                        else
                        {
                            Console.WriteLine("attribute value doesnt exist");
                        }

                    }

                }
                else
                {
                    Console.WriteLine("key- entity name does not exist");
                }
                g.Reply(getList);

            };

            //Make Checkpoint handler
            g.MakeChkpt += (Isis.ChkptMaker)delegate(View v)
            {
                if (autoEntity.Count != 0)
                {

                    Console.WriteLine("entering into Make CheckPoint");
                    List<KeyValuePair<string, List<KeyValuePair<string, string>>>> database = new List<KeyValuePair<string, List<KeyValuePair<string, string>>>>();

//.........这里部分代码省略.........
开发者ID:manvi90,项目名称:WCF-based-Information-Tracking-Service,代码行数:101,代码来源:Program.cs

示例3: Isis_Start

            //public Dictionary<string, Dictionary<string, string>> entity = new Dictionary<string, Dictionary<string, string>>();

            public static void Isis_Start()
            {
                IsisSystem.Start();
                g = new Group("pb476_cs5412");
                int myRank = 0;
                
                
                g.ViewHandlers += (ViewHandler)delegate(View v)
                {
                    IsisSystem.WriteLine("New View: " + v);
                    myRank = v.GetMyRank();

                    if (v.members.Length == 5)
                        go.Release(1);
                };
                g.Handlers[UPDATE] += (Action<string, string, string>)delegate(string key, string value, string attkey)
                {
                    Dictionary<string, string> attr = new Dictionary<string, string>();
                    if (value == "null")
                    {
                        entity.Remove(key);
                    }
                    else if (entity.ContainsKey(key))
                    {
                        entity[key] = attr;
                        attr[key] = attkey;
                    }
                    else
                    {
                        entity.Add(key, attr);
                    }
                    //collection cp = new collection();
                    CS5412_Service cp = new CS5412_Service();
                    cp.Set(key, value, attkey);
                    IsisSystem.WriteLine("New collection: " + key + "/" + value + "/" + attkey);

                };
                g.Handlers[LOOKUP] += (Action<string>)delegate(string key)
                {
                    Dictionary<string, string> attr = new Dictionary<string, string>();
                    string result = null;
                    //attr = entity;

                    if (entity.ContainsKey(key))
                    {
                        result = attr[key];
                    }

                    
                    IsisSystem.WriteLine("=== Query for arg=" + key + "Result" + result);

                    /*List<string> answer = new List<string>();
                    //foreach (collection tp in database)
                        if (Get(key) == key)
                        {
                            IsisSystem.WriteLine("Including " + Get(key) + "/" + GetType());
                            answer.Add(Get(key));
                        }*/

                    g.Reply(result);
                };
                g.Join();
                IsisSystem.WriteLine("Time elapsed is " + stopwatch.Elapsed);

                IsisSystem.WriteLine("Wait until database is full!");
                dbFull.WaitOne();
                IsisSystem.WriteLine("Database is fully populated!");
            }
开发者ID:prashanth08,项目名称:Porting-ISIS2-Cloud-Computing-application-onto-Amazon-EC2-instances-and-achieving-Ordered-Multicast.,代码行数:70,代码来源:CS5412_Service.cs


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