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


C# Udbus.Cancel方法代码示例

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


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

示例1: TestDbusCalls


//.........这里部分代码省略.........

            //result = connector.ReceiveStruct(out recv);
            //Console.WriteLine("ListNames recv result: {0}. msg: {1}", result, recv);

            //using (var msg = connector.ReceiveHandle(out result))
            using(var msg = Udbus.Core.UdbusVisitorFunctions.LoopUdbusFind(connector, visitors, Console.Out, stop).Handle)
            {
                //result = connector.ReceiveStruct(out recv);
                msg.HandleToStructure(out recv);
                Console.WriteLine("ListNames recv result: {0}. msg: {1}", result, recv);

                Udbus.Serialization.UdbusMessageReader reader = new Udbus.Serialization.UdbusMessageReader(msg);
                uint counter = 0;

                foreach (Udbus.Serialization.UdbusMessageReader subreader in reader.ArrayReader(Udbus.Types.dbus_type.DBUS_STRING))
                {
                    string name = subreader.ReadStringValue(out result);
                    if (result != 0)
                    {
                        Console.WriteLine("Error ! {0:d}/0x{0:x8}", result);
                    }
                    Console.WriteLine("Entry {0:d2}: {1}", counter++, name);
                }
            } // Ends using ListNames response
            #endif // _LISTNAMES

            // read_icon
            TestDbusReadIcon(builder, visitors, connector, stop, preNextAction);

            #if _GETSIGNAL
            preNextAction("AddMatch");

            // AddMatch for signal.
            using (var msg = builder.UdbusMethodMessage(
                "org.freedesktop.DBus", "/org/freedesktop/DBus",
                "org.freedesktop.DBus", "AddMatch").Message)
            {
                Udbus.Types.dbus_sig signature = Udbus.Types.dbus_sig.Initialiser;
                signature.a[0] = Udbus.Types.dbus_type.DBUS_STRING;
                signature.a[1] = Udbus.Types.dbus_type.DBUS_INVALID;
                builder.SetSignature(ref signature)
                    .BodyAdd(4096)
                    .BodyAdd_String("type='signal',interface='com.citrix.xenclient.xenmgr.host',member='storage_space_low'")
                    //.BodyAdd_String("type='signal',interface='com.citrix.xenclient.xenmgr.host'")
                ;
                result = connector.Send(msg);
                Console.WriteLine("AddMatch send result: {0}", result);

            }

            preNextAction("LoopSignals");

            // Handle signals and other bits of magic.
            //Console.TreatControlCAsInput = true;
            Console.CancelKeyPress += delegate(Object sender, ConsoleCancelEventArgs consoleargs)
            {
                consoleargs.Cancel = true;
                Console.WriteLine("Setting stop event...");
                stop.Set();
                connection.Cancel();
            };

            try
            {
                Udbus.Core.UdbusVisitorFunctions.LoopUdbus(connector, visitor, Console.Out, stop);
            }
            catch (System.Runtime.InteropServices.SEHException seh)
            {
                Console.WriteLine("Error: " + seh.ToString());
            }
            #endif // _GETSIGNAL

            #if HAVESOMECCODE
            r = 0;
            msg = NULL;
            msg = dbus_msg_new_method_call(serial++,
            "org.freedesktop.DBus", "/org/freedesktop/DBus",
            "org.freedesktop.DBus", "AddMatch");
            if (!msg) {
            dio.io_debug(dio.logpriv, "Unable to create method message for AddMatch\n");
            exit(1);
            }
            MessageInfo::dumpMethodSend(&io_debug, msg);
            dbus_sig signature;
            signature.a[0] = DBUS_STRING;
            signature.a[1] = DBUS_INVALID;
            dbus_msg_set_signature(msg, &signature);
            dbus_msg_body_add(msg, 4096);
            //r |= dbus_msg_body_add_string(msg, "type='signal',interface='com.citrix.xenclient.xenmgr.host'");
            //r |= dbus_msg_body_add_string(msg, "type='method_call'");
            r |= dbus_msg_body_add_string(msg, "type='signal',interface='com.citrix.xenclient.xenmgr.host'");
            r |= dbus_msg_send(&dio, msg);

            loop_dbus(dio, visitor);
            #endif // HAVESOMECCODE
            Console.WriteLine("Press <ENTER> to end connection");
            Console.ReadLine();

            return connector;
        }
开发者ID:jean-edouard,项目名称:win-tools,代码行数:101,代码来源:UdbusCSharpConsole.cs


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