Top

Use csharp sdk in console application

Comments

2 comments

  • Christophe IRLES

    Hi,

    The Rainbow CSharp SDK has been built to be asynchronous.

    You can still create a console application but it's up to you to "synchronize" methods/API you want to use.

    For example, the method "GetContactFromContactIdFromServer" can by used synchronous in this way:

    public Contact GetContactFromContactIdFromServerSync(String contactId)
    {
       Contact contact = null;

       ManualResetEvent pause = new ManualResetEvent(false);
       GetContactFromContactIdFromServer(contactId, callback =>
       {
         if (callback.Result.Success)
           contact = callback.Data;

         pause.Set();
       });
       pause.WaitOne(2000); // <= In case of network trouble, we need also a Timer. Here 2 seconds
       return contact;
    }

    For the Login step, it's a little bit more complex since you need to wait 2 events: ConnectionStateChanged and InitializationPerformed. but it's still possible

    Regards,
    Christophe

    0
    Comment actions Permalink
  • Flavio DOSSENA

    Thanks for your suggestion.

    Please, can you send me a sample for ConnectionStateChanged and InitializationPerformed ?

    Thank you very much.

    Have a nice day

    Flavio 

    0
    Comment actions Permalink

Please sign in to leave a comment.

Still can't find what you need?

  • Contact Us

    Do you have any question about Rainbow? Leave us a message to get more information.

    Contact
  • Ask the Community

    Do you need help? Ask your questions in the Community to get answers from other Rainbow users.

    Post message