Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I'm slowly moving from a business user to the dba/coding side of the house. I've written automation scripts in Access over the last few and am now working on making C# GUIs with Visual Studio to interface with our SQL server tables.

Randomly, I came across a thread on using background threads to handle the workload for things such as button clicks, etc. I was wondering if there were any other standard techniques like this that are used in coding for GUIs. When I google or search forums, everything I find is about visual layout of the GUI (from being a business user, I've been the customer, so I have an idea about GUI layouts (I think...)).

Thank you for bearing with my round about question... like I said, I'm new to this whole coding thing, and am loving it so far...
Posted
Comments
Sergey Alexandrovich Kryukov 23-Sep-13 20:37pm    
Not true. You can find everything about UI. Just use MDSN. You don't even tell us what UI library and technology you want to use (WPF? System.Windows.Forms? Silverlight?, ASP.NET? anything else?).
—SA
Michael Parzyck 23-Sep-13 20:52pm    
I am using system.windows.forms, sry forgot to mention that.

What I'm currently working on is a data entry type interface for SQL server table manipulation. I'm fine with doing the actual data manipulation, but I guess it's my inexperience with OOP that I'm working through with coding efficiently.

I will spend more time on MDSN, as I'm sure most questions can be addressed there. Thanks for the tip.
Sergey Alexandrovich Kryukov 23-Sep-13 21:31pm    
Better (but add it as a tag "WinForm").
—SA
BillWoodruff 24-Sep-13 0:24am    
An interesting question, Michael; I interpret your words as asking for information more "nitty gritty" than theory, but there are many interpretations possible.

Are you asking about specific techniques for programming with the standard Microsoft Controls provided with WinForms .NET in the context of interaction with database tables ?

The strategic decision to use threads in a WinForms app will be influenced by several factors, including whether or not the thread must frequently notify the UI (as in a ProgressBar type scenario) vs. when the thread only signals the UI thread when done.

Can you be a bit more specific about what you are doing ?

1 solution

The question is too vague. "Standard techniques"?

The technique of using additional (non-UI) threads in UI is related to UI thread invocation. You cannot call anything related to UI from non-UI thread. Instead, you need to use the method Invoke or BeginInvoke of System.Windows.Threading.Dispatcher (for both Forms or WPF) or System.Windows.Forms.Control (Forms only).

You will find detailed explanation of how it works and code samples in my past answers:
Control.Invoke() vs. Control.BeginInvoke()[^],
Problem with Treeview Scanner And MD5[^].

See also more references on threading:
How to get a keydown event to operate on a different thread in vb.net[^],
Control events not firing after enable disable + multithreading[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900