简体   繁体   English

C#Winforms .NET框架数据处理

[英]C# Winforms .NET framework Data Processing

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. 我有一个程序,通过单击DataGridView中的一个项目来请求用户输入上的数据,并自动请求给定Stock符号的新信息。 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. 从api服务器接收到数据后,它将排队,后台工作人员将处理数据并通过文本框,图表和各种风险分析来更新UI。

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. 我无法更改服务器的内容,并且响应仅包含一个请求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. 我试图将请求ID存储到列表中,然后在列表中搜索以确定它是用户输入还是更新序列。 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. 但是,这增加了整个过程3-5秒。

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(); 然后对于更新序列,它使用相同的代码,但symbol [0] = sender.ToString(); and Stored_ID(requestID+",[UP]"); 和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. 队列工作者获取响应数据并匹配请求ID以获取标签。 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. 触发3次更新序列后,开始需要15到30秒的时间,UI数据才会显示在UI上。 This is once the worker has finished working the requestID being removed from the stored list. 一旦工作人员完成工作,就从存储列表中删除了requestID。

Everytime the Update Sequence is fired it recieves 8,000 responses within 15 seconds. 每次触发更新序列时,它都会在15秒内收到8,000个响应。

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. 我尝试了4种不同的方式,从仅存储UI请求开始,然后如果没有在列表中自动更新方法。

All the Update method does is Updates the database which the UI uses. Update方法所做的全部就是更新UI使用的数据库。 Then once every 5 min the UI loads the new database. 然后,UI每5分钟加载一次新数据库。

Thank you in advance!! 先感谢您!!

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()). 如果涉及Linq2SQL或EF,我会四处检查以确保正在使用急切的加载(或强制使用.ToList()或.AsEnumerable()进行早期评估,同时避免使用.AsQueryable())。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM