C# Winforms .NET framework Data Processing

c# .net windows

46 观看

1回复

11 作者的声誉

I have a program that request data on User Input from clicking on an item from withing a DataGridView and automatically request new information given the Stock symbol. When data is recieved from the api server it gets queued and background workers process the data and updates the UI via textboxes, charts, and various risk analysis.

I have written an update sequence that updates Heat of the stocks, profit margin, current price. This is where my problem lies. I cannot change what is to the server and the responses only contain an request id.

I have tried to store the request id into a list and then search within the list to determine if it was a user input or an update sequence. By doing so i can add a tag on my end to tell the application where to send the data for processing. However this added 3-5 secs to the entire process.

when data is sent for request here is the code that is being used:

private void QuoteRequest_Click(object sender, EventArgs e)
{
    if (CheckSymbolValidity() == false)
            return;

        string[] symbols = new string[1];
        symbols[0] = this.textBoxSymbol.Text.ToUpper();

        short[] quoteFields = new short[4];
        quoteFields[0] = (short)ActiveTickFeedLib.ATQuoteFieldEnum.ATQuoteFieldLastPrice;

        int requestId = ActiveTickFeed.feed.SendQuoteDbRequest(symbols, quoteFields);

       Stored_ID(requestId+",[UI]");
}

then for the update sequence it uses the same code except symbol[0]= sender.ToString(); and Stored_ID(requestID+",[UP]"); Thus changing the stored tag for the application.

The Queue workers Grab Response data and match the request id to obtain the Tag. Then from that tag it gets what stored methods to use for example:

string[] split = data.Split(new string[] {","}, stringsplitoptions.None);
if(split[1] == "[UI]")
{
     UI_Data(Res_Data); // method for using the data within the UI
}
//method for the update methods
if(split[1] == "[UP]")
{
    UP_Data(Res_Data);
}

All this does is point the worker in how to process the data. Once the Update Sequence has been fired off 3 times, it starts to take 15-30 secs, for UI data to show up on UI. This is once the worker has finished working the requestID being removed from the stored list.

Everytime the Update Sequence is fired it recieves 8,000 responses within 15 seconds.

My Question Being, is there a better way to do this? Can i use a background thread to run a duplicate modified version of only the update sequence on timers.

Any Suggestions would be helpful!! I have tried 4 different ways from only storing UI request, and then if not in list automatically an Update Method.

All the Update method does is Updates the database which the UI uses. Then once every 5 min the UI loads the new database.

Thank you in advance!!

作者: mike smith 的来源 发布者: 2017 年 12 月 27 日

回应 1


0

44 作者的声誉

That many responses could be a symptom of iterative vs set-based coding styles. If Linq2SQL or EF is involved I'd check around to ensure eager loading is being used (or force early evaluation with .ToList() or .AsEnumerable() while avoiding .AsQueryable()).

作者: Craig Simon 发布者: 2017 年 12 月 27 日
32x32