I'm using a API called WindAPI which provided the financial data from China markets. This API provides a method call wsq() which will provide the RealTime price data to user's program through a callback function!
I write some simple codes in c#,trying to use this wsq() method, but get no results. I wonder there must be some error in codes, but just can't find it! I'm new to both C# and programming, so if it's a rookie mistake, don't laugh at me:)
Here's the codes, I'll give as much comments as possible, so you can find the misunderstanding in it quickly.
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);
}
}
}
My understanding is that, when I request the data service by using w.wsq(), when the prices change(that's the event), myCallback() will be called and export the data on screen!
The reason I add a readline() is to prevent the main program runs too fast, and end before the event(price changing). In that situation, the myCallback() would have no chance to be called!
But when I run the codes, after "errorId = 0" shows, I wait several minutes and still get no results! I confirmed that the price has changed(it usually changed within seconds).
Here is the result I get, and I can't find the reason....(I just type the lines in screen)
>>Begin......
>>New API created!
>>API log on!
>>errorId = 0
and then the prgram just paused there and nothing more happened! So I'd be very thankful if someone could explain that to me....
Thank you in advanced!
Updated: According to the comments below, I give the zip files of my solutions. Also with the API dll and it's source codes.
so, anyone help?