Enhance UI Responsiveness in c# - c#

I have created an POS application using Dynamic buttons, dynamic table layouts, and other controls in one form. The generated dynamic buttons is based on the number of data queried from the database(using OPEN ACCESS ORM).
My problem is whenever I run the application, the UI responsiveness is slow. For Example when I click on a category button, the sub category buttons appears (These are dynamic generated buttons), for it to appear, it would take few seconds to appear, then there are some little flash on the screen.
What will I do? What strategy should I perform.
Thank you. So much

Make sure the buttons do not have time consuming actions. And if they do:
use a waitcursor (simple solution, but not liked by most users)
use a thread to perform the action (might complicate other actions regarding thread safety).

Related

How to create Work flow with custom controls

I would like to create a work flow with some custom controls and control lines. For the same i want to create my own editor to edit / Create work flow.
Can some one suggest where i can start / provide some references to start.
Thanks.
The question is too broad to give it a good and simple answer without writing a book. My advice is to split your project into sub tasks:
Create a control that e.g. looks like a box that shows some editable information (e.g. name)
Create a canvas area and place the control on it
Add Drag&Drop to the control so the user can drag it across the
canvas area
Add a second control and draw a line between them.
Create an UI to add an arbitrary number of controls to the canvas (e.g. via Drag&Drop)
Add commands to the control that represent the action (could use
ICommand)
Create a workflow manager that interprets and executes the commands
in the defined order
Extend the editor e.g. to enable the user to reconnect the lines or
to add rules and priorities to the control or even to choose a set of commands from a pool and assign them to the control
Make everything look nice
Now that you have separate tasks, you can focus on each and research them individually. Step by step. Your questions therefore become more precise and easier to answer (for yourself and others).
Why re-invent the wheel?
You could re host the windows workflow designer.
https://learn.microsoft.com/en-us/dotnet/framework/windows-workflow-foundation/samples/designer-rehosting
I've seen other articles talk about this in more detail but I couldn't immediately find them and you could of course just search yourself.
There is a huge amount of functionality in that thing which would take you forever to replicate.

Add controls to GUI in background worker

I have a form with a top and bottom panel.
The user will be making selections in the top panel, and each time they change a value on one key field I destroy the controls in the bottom panel, then make a time-consuming call to another application (via COM) and add a list of new controls being added. This refresh process takes several seconds.
I'd like to be able to disable the bottom panel while it's being refreshed, and allow the user to be able to keep working in the top panel. Of course, this is all one GUI running on one thread.
Illustrated:
I played with BackgroundWorker, but of course it cannot directly create controls on the main thread's GUI.
Is it possible for me to do this, i.e. allow one part of the GUI to be disabled and rebuilt in the background, while the user continues to work in on another part?
Is it possible for me to do this, i.e. allow one part of the GUI to be disabled and rebuilt in the background, while the user continues to work in on another part?
In general, no. GUI elements/controls must all be created and used on the UI thread, and nowhere else.
The best way to create this type of scenario is typically to use a BackgroundWorker or other technique to get the required data on a background thread, then build your UI after the data has been loaded completely.

User controls to load asynchronously

We are developing a winform application that does data intensive work. Our queries (BI tasks) can take up to a minute to conclude. We have four important processes, and we want to show their state in one single window. With that in mind, we have developed four user controls, each one shown in our main form. There are three researchers working on their own user controls, and we are integrating them on the main application.
The problem is, when one user control is refreshing, the application will freeze. What should my approach be to make the user controls refresh asynchronously? Is there a solution that I can use, in order to create a Base class or interface that will force the developers of the other controls follow the same method?

WPF Application starts up too slowly

I have problems with my current application which is developed in C# with WPF. The application consists of different flowcharts each contained in its own separate window.
At start-up all flowchart classes are instantiated and initialized in their window. Then the windows are made invisible and the flowchart menu appears.
With each new flowchart the application start up gets slower. The window initialization seems to consume a lot of time.
How could I approach this problem?
I thought of initialization when first needed or background initialization.
Note: I forgot a very important fact: The flowchart menu is created based on the other flowcharts, since every single flowchart is rendered as an image in order to display a thumbnail menu button. This is the problem which brough me to the performance impact anyway.
You have many approaches to this problem.
First, you have to remove the initialization from the c'tor.
Where to move it?
Either to Window_onLoad event, this way the app will first loaded and then start initializing the flow charts (using a new thread will avoid UI freeze).
Or once the user selects the required flow chart from the menu, you show the window and start initializing the inner flow chart, display a nice "loading.." animation while busy, and show the flow chart once you done.
I'd prefer the second approach, init each object when it's needed.
Edit:
Since you have to render the thumbs based on the flowcharts, i would do the following:
Move the flowcharts init to the main window Loaded event, and init each flowchart on a different thread, while busy display a nice "please wait.." animation. This way the main app window appears, the user see that the app is loading, your thumbs will be created simultaneously therefore loading time will be reduced. Once all the thumbs created, hide the animation.
Don't instantiate all the flowchart classes before you load the main window.
As a first approach I'd go with initialisation when needed.
If this proves to be unpopular as people don't like waiting then go for a background initialisation with the most popular or most recent flowchart instantiated first. This will be right most of the time so the user won't have to wait.
If you need to have a thumbnail of the flowchart then why not save the thumbnail from when the flowchart was last rendered and use that? So, when the flowchart is created first saved save a thumbnail at that point. Then when you populate the list pull that out of the database/off disk and render that.
Nobody's mentioned profiling yet, but why not just try (the last paragraph of) this?
You will easily see the dominant reason for the long time being taken.
Chances are, it's something fairly trivial that you can easily fix.
If you want more of an explanation, look here.

Non intrusive 'live' help system

I'm searching a C# component or code snipped that does something like that:
I want to inform new users about the most important program functions if he opens a new window for example.
It should be a box showing text (formated if possible) that is of course not modal and has some mechanism to 'go out of the way' if the user enters the textbox area. So that he can access what's underneath it. Alternativly the window could also stick to the border of the window, but there needs to be a way that this also works if the window is maximized.
So I want to present him with a short introduction of what he can do in every corner of my app most painlessly.
Thank you!
I use a "bar" at the top of every window to display some information about the current window/dialog.
Use tooltips. They can be programmatically controlled, and you can have them appear at will. You'll need to add the functionality to your app to keep track of what tooltips have been shown to the user already.
You can add a "balloon" style by setting the IsBalloon property to true.
You can also replace them with smaller descriptions for when the user wants to hover over the control and have them displayed again.
I'm already using tooltips heavily. However, they aren't very practical when displaying bigger amounts of data and they are bound to specific user actions.
Have you considered having a contextual menu for each form / page which contains links to Adobe Captivate style presentations for each available task? That way the user can investigate an example of how to achieve a task relating to what they are trying to achieve from within the application / site.
This approach would require a good deal of maintenance and management if your code changes regularly but coordinating it with a training department can provide rich help features in your application.
See http://www.adobe.com/products/captivate/ for more information.

Categories