Esempio n. 1
0
        static void Main(string[] args)
        {
            try
            {
                var worker = new GearmanThreadedWorker();
                var host   = "smeagol";
                worker.AddServer(host, 4731);
                worker.AddServer(host, 4730);
                worker.SetClientId("my-threaded-worker");
                worker.RegisterFunction <string, string>("reverse", DoReverse, Serializers.UTF8StringDeserialize, Serializers.UTF8StringSerialize);
                worker.RegisterFunction <string, string>("reverse_with_status", DoReverseWithStatus, Serializers.UTF8StringDeserialize, Serializers.UTF8StringSerialize);

                Console.WriteLine("Press enter to start work loop, and press enter again to stop");
                Console.ReadLine();

                worker.StartWorkLoop();

                Console.ReadLine();

                worker.StopWorkLoop();

                Console.WriteLine("Press enter to quit");
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Got exception: {0}", ex);
                return;
            }
        }
Esempio n. 2
0
        public void AdvancedWorker()
        {
            var worker = new GearmanThreadedWorker();
            worker.AddServer("gearman.example.com");
            worker.AddServer("10.0.0.2", 4730);
            worker.SetClientId("my-client");

            worker.RegisterFunction<IList<string>, IList<OEmbed>>("GetOEmbeds", GetOembedsFunction,
                Serializers.JsonDeserialize<IList<string>>, Serializers.JsonSerialize<IList<OEmbed>>);

            // start worker thread
            worker.StartWorkLoop();

            // do other stuff

            // when it's time to stop
            worker.StopWorkLoop();
        }
Esempio n. 3
0
        public void AdvancedWorker()
        {
            var worker = new GearmanThreadedWorker();

            worker.AddServer("gearman.example.com");
            worker.AddServer("10.0.0.2", 4730);
            worker.SetClientId("my-client");

            worker.RegisterFunction <IList <string>, IList <OEmbed> >("GetOEmbeds", GetOembedsFunction,
                                                                      Serializers.JsonDeserialize <IList <string> >, Serializers.JsonSerialize <IList <OEmbed> >);

            // start worker thread
            worker.StartWorkLoop();

            // do other stuff

            // when it's time to stop
            worker.StopWorkLoop();
        }