|
A similar way is possible using an object-oriented framework like .NET. Instead of thinking procedurally, though, thing about how these objects react with each other, or with other objects.
For instance, you could code an event on the object that starts all the threads, for which they would handle. You should invoke these delegates attached to the event in an asynchronous manner, most likely. You could also add events to the threaded object but then the invoking class has to keep track of them and add and remove delegates. The first way makes more sense.
One thing that may help is that the C# compiler (I believe the VB.NET compilers does as well) generates synchronous (Invoke ) and asynchronous invocation methods (BeginInvoke , EndInvoke ). that are visible in the code editor when the delegates are declared in the current project. For more on asynchronous calls in .NET, see Including Asynchronous Calls[^] in the .NET Framework SDK.
It seem, though, like you are headed in the right direction. The only thing you have to watch out for is that you invoke the methods from the calling thread in the thread that contains the object.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Where is a discussion of the current and future optimizations that the C# compilers do? When I see things like the following I start to question my faith in csc being good at optimizing. (The same kind of thing shows up in cordbg when looking at the JIT code for a similar example.)
% cat y.cs
using System;
class A {
bool On { get { return true; } }
public void Print() {
if (On) {
Console.WriteLine("On");
}
}
}
class ConditionalTest {
static void Main()
{
A a = new A();
a.Print();
}
}
% csc /optimize+ y.cs
Microsoft (R) Visual C# .NET Compiler version 7.10.3052.4
for Microsoft (R) .NET Framework version 1.1.4322
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.
% ildasm y.exe
.method public hidebysig instance void Print() cil managed
{
// Code size 19 (0x13)
.maxstack 2
IL_0000: ldarg.0
IL_0001: call instance bool A::get_On()
IL_0006: brfalse.s IL_0012
IL_0008: ldstr "On"
IL_000d: call void [mscorlib]System.Console::WriteLine(string)
IL_0012: ret
} // end of method A::Print
%
At least the compiler eliminates the "if" test when "On" is replaced with "true" in the test.
|
|
|
|
|
Visual Studio has the nifty-looking selection colors when you hover over the main menu. I am in the process of writing a custom control, and I would like to use those colors (Windows Theme-depended obviously) for the selection mechanism in my custom control.
It seems System.Drawing.SystemColors isn't the proper way to get them; I can't find a SystemColor that is the correct color across all Windows Theme skins; for example, using the standard Blue Luna theme, SystemColors.InactiveCaptionText is the correct color for the internal region of the selection. However, using the Olive theme, that is not the correct color.
How can I get the correct colors needed to draw a VS-style selection?
Thanks ahead of time.
The graveyards are filled with indispensible men.
|
|
|
|
|
Sometimes Microsoft changes the normal colors of a control by changing the RGB components, like adding the difference between the current color and FF (for each component). This will lighten the color. There are also SystemColors that should already have such values, too, like ControlLight and ControlLightLight . You could try these as well.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
I wrote a program to go through all the SystemColors and compare them with what Visual Studio uses. The result was that there were some colors that Visual Studio uses (for instace, to draw a Visual Studio menu using the Luna Blue theme, SystemColors.Highlight can be used for the outer border, and SystemColors.InactiveCaptionText can be used for the inner region). However, if I switch themes, say to the Olive theme, SystemColors.Highlight and SystemColors.InactiveCaptionText no longer are the correct colors. In addition to checking all the SystemColors , I've also check through all system colors put through ControlPaint.Dark , .DarkDark , .Light , and .LightLight and still haven't found the correct colors!
Ack.
The graveyards are filled with indispensible men.
|
|
|
|
|
As I mentioned before, another thing they sometimes do is modify the RGB components of the color to get such an effect (adding to lighten, subtracting to darken). You could do the same thing if the SystemColors don't work for you.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Does anyone know how to programmatically position the mouse on a control in c#?
Darryl Borden
Principal IT Analyst
darryl.borden@elpaso.com
|
|
|
|
|
Cursor.Position = somePoint;
If you want to limit that point to be on the control, use the control's .PointToClient method. For example,
Point somePoint = new Point(0,0);
Cursor.Position = myControl.PointToClient(somePoint);
The graveyards are filled with indispensible men.
|
|
|
|
|
I am new to .NET. I have 1 solution with 2 projects. Project 2 compiles into a class library which is reference from Project 1. I wish to walk into the source of my reference during debug. Can I do this? BTW, both projects are set to debug...
Thanks
Ralph
|
|
|
|
|
Should work just fine...just set your break points and launch it.
|
|
|
|
|
Thanks but it doesn't. So here is a bit more info. Project 1 is a ASP.NET application, so I lauch a web page. I wish to trace into the method that is in the reference. So if I CAN'T trace into the method, what should I check...
Thanks
Ralph
|
|
|
|
|
Debugging has to be enabled on the server. In IIS, you can configure this in the Application Configuration. The .NET Framework debugging tools (from the SDK) also have to be installed (from what I've read), so install the SDK on the server (not just the runtime).
There is a lot of documentation on this in the KB at http://support.microsoft.com[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for all the help. I realized (later) that these were stubs, RPC calls to the server...
|
|
|
|
|
hi all
I want to trace the parallel port & serial port
thanks;)
|
|
|
|
|
|
|
|
if u mean to read and send data to ports there are numbers of ways.
for parallel port u can use outport and inport commands.
for serial port it is little more difficult. there are number of article in codeproject itself
|
|
|
|
|
how do i specify the build order of the projects in a solution? for example, if i have a deployment project in a solution, how do i make that build last, so the deployment project will include the latest versions of the assemblies?
|
|
|
|
|
godzooky wrote:
for example, if i have a deployment project in a solution, how do i make that build last, so the deployment project will include the latest versions of the assemblies?
The projects are built based on reference dependency. This is why you can't have circular references in your projects. You're deployment project should reference the projects on which it depends, and therefore will be built last.
Marc
Latest AAL Article
My blog
Join my forum!
|
|
|
|
|
Hi,
I'm new to the windows datagrid control. I'm trying to create an application that displays the contents on an access database. I've got that part working so far; my question is how can I have the datagrid & access database accept any changes that the user enters into the datagrid. Is their a way for the datagrid's contents to be dumped into the access database after a change is made? I don't want to do it manually, it could get messy.
Thanks
|
|
|
|
|
You have to take look at htese class:
Use a OleDbDataADapter to fill a DataSet and bind it to DataGrid , then each change reflected to datagrid, you can update access database with OleDBdDataAdapter.Update() method. If you search for these classes you can find samples in this site and MSDN.
Mazy
"Improvisation is the touchstone of wit." - Molière
|
|
|
|
|
Hi Mazy,
I have a datagrid in win form that when a change to a record on that same form occurs how can I get the datagrid to refresh with new updates?
I have the datagrid bound to a dataview. So some how need way to update the dataview I'm guessing.
Thanks,
JJ
|
|
|
|
|
MrJJKoolJ wrote:
I have the datagrid bound to a dataview. So some how need way to update the dataview I'm
I told you how to do this. The dataview only for VIEW, you bind it to datagrid and when something change in datagrid it reflected in dataview automaticly.
MrJJKoolJ wrote:
can I get the datagrid to refresh with new updates?
You don't need to do that, as I told you , yu made change in DataSet, then it AUTOMATICLLY it is reflected in your datagrid.
Mazy
"Improvisation is the touchstone of wit." - Molière
|
|
|
|