I've been playing with Vsync from a C++ extension called C++/CLI (a Microsoft .NET product). The code shown below illustrates the coding style that works. To compile it you need to compile VsyncLib, add a reference to the VsyncLib.dll file to your project, and then click the C/C++ "General" tab in project properties and add the pathname to your VsyncLib.dll file on the "Resolve #using References" property.

Sorry about needing to disable the C4538 warning (the pragma); you can leave that out if you like. Inhibits a warning incorrectly generated as a result of a known compiler issue.

You may be curious about the method Group::thisGroup(). I added this because in {C++/CLI} you can't pass a pointer to a managed object outside of the function activation that allocated it via gcnew. Thus, when I tried to find a way to code g->Reply(...) I discovered that "g" is inaccessible and that this is locked in by the CLI language rules! Group::thisGroup() returns a Group^ reference to the group in which the current message was delivered, and that does the job.

One more comment: Either compile VsyncLib with ISIS_LOGGING = false (or set Vsync::VSYNC_LOGGING = false befoe calling VsyncSystem::Start()), or make sure to create a folder called "logs" in the current directory when you launch the program, for the Isis log files. Otherwise you'll get a can't create file exception.

// CPlusPlus.cpp : main project file.

#include "stdafx.h"
#using <VsyncLib.dll>
using namespace Vsync;
using namespace System;

void GotNewView(View^ v)
       Console::WriteLine("Got a new view: " + v->ToString());

public delegate void GotAnInt_T (int i);
void GotAnInt(int i)
       Console::WriteLine("Got an int: {0}", i);

public delegate void GotTwo_T (String ^s, double d);
void GotTwo(String^ s, double d)
       Console::WriteLine("Got a string: <{0}> and a double: {1}", s, d);

public delegate void SendsReply_T(int i);
void SendsReply(int i)

int main(array<System::String ^> ^args)
       Console::WriteLine("Hello World... starting Vsync");
       Console::WriteLine("After VsyncSystem::Start()");
#pragma warning (push) 
#pragma warning (disable: 4538) 
	   Group^ g = gcnew Group("test"); 
#pragma warning (pop)
       g->RegisterViewHandler(gcnew ViewHandler(GotNewView));
       g->Handlers[0] += gcnew GotAnInt_T(GotAnInt);
       g->Handlers[0] += gcnew GotTwo_T(GotTwo);
       g->Handlers[1] += gcnew SendsReply_T(SendsReply);
       Console::WriteLine("After setting up group, calling Join");
       Console::WriteLine("After Join testing Send");
       g->Send((int^)0, 12345);
       g->Send((int^)0, "Aardvarks are animals", 78.91);
       Console::WriteLine("After Send, testing Query");
       Collections::Generic::List<int>^ results = gcnew Collections::Generic::List<int>();
       int nr = g->Query(Group::ALL, 1, 6543, gcnew EOLMarker(), results);
       Console::WriteLine("Received {0} results!", nr);
       for each(int x in results)
                Console::WriteLine("    Result={0}", x);
       Console::WriteLine("After Join calling WaitForever()");
       return 0;

Last edited Nov 19, 2015 at 8:13 PM by birman, version 4