multithreading - C# Step by Step Execution -


I am creating an app that uses APIs and places one format in another format converter. I have a way (actually one click event) that does this:

  Private Wide Button ScanAndParse_Click (Object Sender, EventArgs e) {short scan_result = scanner_api.Scan (); If (scan_result == 1) parse_api.Parse (); // This will check for a saved image on the disk scanner_api store, and then change it. }  

The problem is that if condition (scan_result == 1) is evaluated in the medieval period, then it just does not work.

I do not return the CLR until the API returns the convenient results.

Note

Just doing something like this:

  Private Zero Button ScanAndParse_Click (Object Sender, EventArgs e) {Short scan_result = scanner_api.Scan () ; MessageBox.Show ("result =" + scan_result); If (scan_result == 1) parse_api.Parse (); // This will check for a saved image on the disk scanner_api store, and then change it. }  

This works and displays results.

Is there any way to do this, how?

Thanks a lot!

UPDATE:

There is an event on the scanner API:

  public event and sqn () // comes when scanning the image.  

But I do not know how to use it. Any ideas?

It really depends on the API works. If scanner_api.Scan () is, then it will sit on that line which will result in a result. After getting results, if your evaluation will make your UI unresponsive, you have to apply some sort of threading to do it in the background. I am guessing through your question that this API is not the way to work .

This is another way that can work, how many times you see what the results are. You do not want to constantly check and use all your resources (such as the CPU) To check on. Sheldon's answer with the timer gets this.

At least one other way may work when the situation is updated, you send a callback function to the API to call. It can be applied as an event (Representative) passed as such a parameter or as a regular representative, you will often see them applied as "Onstatus Chained", "Onc", etc.

Actually, it supports the API. Voting usually works, others have to give support. If possible, check your API documentation for example.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -