static void Main(string[] args) { bool useListener = true; OpenDDSharp.Ace.Init(); ParticipantService participantService = ParticipantService.Instance; DomainParticipantFactory domainFactory = participantService.GetDomainParticipantFactory(args); DomainParticipantQos qos = new DomainParticipantQos(); qos.EntityFactory.AutoenableCreatedEntities = false; qos.UserData.Value = Encoding.UTF8.GetBytes("sometext"); DomainParticipant participant = domainFactory.CreateParticipant(42, qos); if (participant == null) { throw new Exception("Could not create the participant"); } DomainParticipantQos aux = new DomainParticipantQos(); ReturnCode ret = participant.GetQos(aux); aux.EntityFactory.AutoenableCreatedEntities = true; ret = participant.SetQos(aux); if (participant != null) { TestStructTypeSupport support = new TestStructTypeSupport(); string typeName = support.GetTypeName(); ReturnCode result = support.RegisterType(participant, typeName); if (result != ReturnCode.Ok) { throw new Exception("Could not register the type"); } Topic topic = participant.CreateTopic("TopicName", typeName); Publisher publisher = participant.CreatePublisher(); if (publisher == null) { throw new Exception("Could not create the publisher"); } DataWriter dw = publisher.CreateDataWriter(topic); if (dw == null) { throw new Exception("Could not create the datawriter"); } TestStructDataWriter dataWriter = new TestStructDataWriter(dw); Subscriber subscriber = participant.CreateSubscriber(); if (subscriber == null) { throw new Exception("Could not create the subscribre"); } MyDataListener listener = null; if (useListener) { listener = new MyDataListener(); } DataReader dataReader = subscriber.CreateDataReader(topic, listener, StatusKind.DataAvailableStatus); if (dataReader == null) { throw new Exception("Could not create the datareader"); } WaitSet waitSet = null; StatusCondition statusCondition = null; if (!useListener) { waitSet = new WaitSet(); statusCondition = dataReader.StatusCondition; waitSet.AttachCondition(statusCondition); statusCondition.EnabledStatuses = StatusKind.DataAvailableStatus; new System.Threading.Thread(delegate() { ICollection <Condition> conditions = new List <Condition>(); Duration duration = new Duration { Seconds = Duration.InfiniteSeconds }; waitSet.Wait(conditions, duration); foreach (Condition cond in conditions) { if (cond == statusCondition && cond.TriggerValue) { StatusCondition sCond = (StatusCondition)cond; StatusMask mask = sCond.EnabledStatuses; if ((mask & StatusKind.DataAvailableStatus) != 0) { DataAvailable(dataReader); } } } }).Start(); } TestStruct test = new TestStruct { RawData = "Hello, I love you, won't you tell me your name?" }; test.LongSequence.Add(20); test.LongSequence.Add(10); test.LongSequence.Add(0); test.StringSequence.Add("Hello,"); test.StringSequence.Add("I love you"); test.StringSequence.Add("won't you tell me your name?"); test.LongDoubleType = 1.1; test.LongDoubleSequence.Add(1.1); test.LongDoubleSequence.Add(2.2); test.LongDoubleSequence.Add(3.3); test.LongArray[0, 0] = 1; test.LongArray[0, 1] = 2; test.LongArray[0, 2] = 3; test.LongArray[0, 3] = 4; test.LongArray[1, 0] = 1; test.LongArray[1, 1] = 2; test.LongArray[1, 2] = 3; test.LongArray[1, 3] = 4; test.LongArray[2, 0] = 1; test.LongArray[2, 1] = 2; test.LongArray[2, 2] = 3; test.LongArray[2, 3] = 4; test.StringArray[0, 0] = "Hello,"; test.StringArray[0, 1] = "I love you,"; test.StringArray[1, 0] = "won't you tell me"; test.StringArray[1, 1] = "your name?"; test.StructArray[0, 0] = new BasicTestStruct() { Id = 0 }; test.StructArray[0, 1] = new BasicTestStruct() { Id = 1 }; test.StructArray[1, 0] = new BasicTestStruct() { Id = 2 }; test.StructArray[1, 1] = new BasicTestStruct() { Id = 3 }; test.LongDoubleArray[0, 0] = 1.1; test.LongDoubleArray[0, 1] = 2.2; test.LongDoubleArray[1, 0] = 3.3; test.LongDoubleArray[1, 1] = 4.4; test.StructSequence.Add(new BasicTestStruct() { Id = 1 }); test.StructSequence.Add(new BasicTestStruct() { Id = 2 }); test.StructSequence.Add(new BasicTestStruct() { Id = 3 }); result = dataWriter.Write(test); System.Threading.Thread.Sleep(1000); if (!useListener) { waitSet.DetachCondition(statusCondition); } participant.DeleteContainedEntities(); domainFactory.DeleteParticipant(participant); } participantService.Shutdown(); OpenDDSharp.Ace.Fini(); Console.WriteLine("Press ENTER to finish the test."); Console.ReadLine(); }