Using a callback function provided by the API but not getting any results? (WITH#)

I use an API called WindAPI , which has provided financial data from China's markets. This API provides a call to the wsq () method , which will provide RealTime price data for the user program through a callback function !

I am writing some simple codes in C # trying to use this wsq () method, but I am not getting any results. It is interesting that there should be some error in the codes, but simply cannot find it! I am new to C # and programming, so if this is a rookie mistake, don't laugh at me :)

Here are the codes, I will give as many comments as possible so that you can quickly find a misunderstanding.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//-----------------------------
using WAPIWrapperCSharp;  //the namespace in API dll(official provided)
using WindCommon;         //the namespace to process the data formats (official provided)

namespace WSQ2String
{
    class WSQ2StringSample
    {
        static void Main()
        {
            Console.Write("Begin......");
            Console.ReadLine(); 
            //--------------------creat the new API object and log on
            WindAPI w = new WindAPI();
            Console.WriteLine("New API created!");
            w.start();
            Console.WriteLine("API log on!");
            //--------------------request for the realtime data through w.wsq() method
            int errorId = 0;
            ulong reqId = w.wsq(ref errorId, "150195.sz", "rt_date, rt_time, rt_lastest", "", myCallback);
            Console.WriteLine("errorId = {0}", errorId);
            //----adding a control line which will stop the main program and wait for myCallback function to be called
            Console.ReadLine();    //after the data arrived, the test is over, and we press a key to let the main program continue
            w.cancelRequest(reqId);
            w.stop();
            Console.Write("End......");
            Console.ReadLine();
        }
        //----
        static void myCallback(ulong reqId, WindData wd)
        {
            Console.WriteLine("wsq data gotback......");
            //----transfer the official WindData format to String, and output to the screen 
            string s = WindDataMethod.WindDataToString(wd, "wsq");   //the method is in WindCommon namespace 
            Console.Write(s);
        }
    }
}

I understand that when I request a data service using w.wsq (), when prices change ( that event ), myCallback () will be called and export the data to the screen!

The reason I add readline () is to prevent the main program from working too quickly and to end the event (price change). In this situation, myCallback () will not have a chance to be called!

But when I run the codes, after the appearance of "errorId = 0" I wait a few minutes and do not get any results! I confirmed that the price has changed (usually it changed within a few seconds).

Here is the result that I get, and I can’t find the reason .... (I just type the lines on the screen)

>>Begin......
>>New API created!
>>API log on!
>>errorId = 0

, ! , - ....

!


: , zip . dll API .

dll

, - ?

+4

All Articles