|
Actually, an instance of the control exists even at design-time but you must still make sure the handle exists (IsHandleCreated ) before invoking anything that requires a valid window handle.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You're trying to call invoke on the control before the control's window is created and the handle is assigned.
I get around this with an if/else
if (myControl.IsHandleCreated)
{
}
else
{
}
Grim (aka Toby) MCDBA, MCSD, MCP+SB
|
|
|
|
|
Another common way is if the handle isn't created (see IsHandleCreated ) to queue the operation and invoke it when the HandleCreated event if fired. Many classes in the .NET FCL (especially in Windows Forms) do this.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I've never actually had to do it, so I'm curious as to how it gets queued? I'd tear into the class code with the disassembler but I'm nowhere near a machine with VS.NET on it at work.
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
All you need is the .NET Framework SDK (which requires the .NET Framework). VS.NET just installs the SDK if you opt for it, but it doesn't come with just the SDK as well.
If you were to set a property for example, the set accessor would contain something like this:
if (IsHandleCreated)
{
SendMessage(Handle, SOME_MESSAGE, 0, value);
fieldSet = true;
}
else
{
fieldSet = false;
}
fieldName = value; In the override to OnHandleCreated , you'd have something like this:
if (!fieldSet)
SendMessage(Handle, SOME_MESSAGE, 0, fieldName); To do this with delegates wouldn't be a whole lot different since you can store the delegate in a field or an IList and invoke it later.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I thought of that, but was quickly shot down. I can't install it on anything where I work...
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Nevermind. I found a couple of examples of the technique.
I've been up for four hours and still can't keep my mind or eyes open...
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi all,
I need some advice on the best method to impelemt some functionality.
I have a reader obj that reads all the files in a folder, running in a thread. After each file has been read I call a processor obj to manipulte the data and fill a database. I'd like to process one file while reading the next, but limit the processor to only one instance (to prevent duplication of data in the DB). If the reader finishes reading before the processor it should wait until the processor is done its current data load, but if the porcessor has finished then the reader should make a new processor and then continue to read the next file.
So whats the best method of controling the reader depending on the state of the processor?
I should point out that I'm fairly new to C# (six months)
Thanks
|
|
|
|
|
If your only going to be using a single instance processor, why read ahead of it? You're not gaining any real performance benefit because of the single threaded nature of your design. One thread is constantly waiting for another to complete it's work. The FileStream classes already do read/write caching on their own, so why duplicate its effort?
If you could use a multiple instance processor, instead of a single, THEN you'd see the performance gain. Also, your reader object shouldn't be reading the files itself. Your design should have an engine that hunts down files, then passes the filename to a threaded instance of the processor. That way, the processor thread is doing the reading and processing of the file while your engine goes on it's merry way to launch another processor on the next file. The thread pool could be used for such a task. That way, you wouldn't have to include very much code to do thread management.
I only say this because I did something similar to this a few years ago. But in my case, the database made sure I wasn't duplicating data, not my processor objects.
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for your comments.
The majority of the time the app will be run on a single instance processor machine, but there may be a case where the volume of data is so large a multi machine could be used.
I wish the database would control data duplication, but the data is so poor and badly supplied that I have to do all the checking that I can. For example the data is in XML format and one 33mb file had over 10,000 violations against the schema, but it was well formed!
In the interests of simplicity I leave it as single threaded.
|
|
|
|
|
I need to use msdn not through VS IDE. like standalone help files.
is it possible ? if it is then which file i want to execute ?
Sreejith S S Nair
|
|
|
|
|
You should have a shortcut in your start menu somewhere ...
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
Let me clarify the question once again.
i don't have any menu or link which will connect MSDN index page. I have only the installation folder.
if i want to open help index with using VS IDE, what i want to do ?
Sreejith S S Nair
|
|
|
|
|
Hi,
certainly possible...
Microsoft distributes MSDN seperately in the name of "MSDN Library Edition [month][year]" under the heading "Microsoft Development Network"... if I'm not wrong.
The full installation comes in 3 CDs. After installation you can find "Microsoft Development Network" in your "programs" menu. Thatz really the full and complete MSDN in real sense...
regards,
Aryadip.
Cheers !! and have a Funky day !!
|
|
|
|
|
Please first read the question and then answer.
I have MSDN installation in my machine. And i need to use that help file with out any other program( like if you press F1 in VS IDE you will get help).
otherwise tell me which file that VS IDE using to show the searched content when we press F1.
Sreejith S S Nair
|
|
|
|
|
I don't have VS.NET on any machine at work here, so I'm trying to do this from memory...
Goto the Help menu is VS.NET and pick Index, or Help Index, or something like that.
[EDIT]
If you have the MSDN installed with VS.NET, yes, you SHOULD have an incon for it under Start/Programs/Microsoft Developer Network.
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
The following is copied from the shortcut I use to launch MSDN. It's not as simple as double-clicking on a file.
Note that this is specifically for the April, 2004 installation of MSDN.
"C:\Program Files\Common Files\Microsoft Shared\Help\dexplore.exe" /helpcol ms-help://MS.MSDNQTR.2004APR.1033
Grim (aka Toby) MCDBA, MCSD, MCP+SB
|
|
|
|
|
There is a shortcut in the VS.NET product folder. If you want to execute this without the shortcut, you need to use the path to dexplore.exe (typically in C:\Program Files\Common Files\Microsoft Shared\Help, though you should use Environment.SpecialFolder.CommonProgramFiles pased to Environment.GetFolderPath to get the C:\Program Files\Common Files since it can be redirected or on a different drive than C:). Then pass a command-line param like so:
string dexplorePath = Environment.GetFolderPath(
Environment.SpecialFolder.CommonProgramFiles);
dexplorePath = Path.Combine(dexplorePath, "Microsoft Shared\Help\dexplore.exe");
Process.Start(dexplorePath, "/helpcol ms-help://ms.vscc");
Process.Start(dexplorePath, "/helpcol ms-help://ms.vscc.2003");
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have a very odd problem with J# and threads.
I have a client with a gui and a connection class that is in another thread. At first only parts of the GUI loads, most tabs are not added at this point. Then I connect and check for password, if that is correct I want to load the other tabs. Oddly it loads the first one and that one is empty.
The connection class in an observer that the GUI is listening at.
And when I debug I get this error message:
"An unhandlet exception of type 'System.ArgumentException' occured in system.windows.forms.dll
Additional information: Controls created on one thread cannot be parented to a control on a different thread"
Any idea what might be wrong?
|
|
|
|
|
First, this forum is for C#, not J#.
*** Note to Admins: We need to create a J# Forum! ***
Is your connection class creating the controls? From a design standpoint, it really shouldn't be doing this. It's a connection class, not a GUI class...
But if you must, you would have to supply a delegate function on your form for the connection class to call using wheteverFormName.Invoke(). This function would then have to create the new controls. The controls absolutely cannot be created directly by the connection class.
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm a new C# coder but is forced to work with J# on this single project, and I hate it .
Anyhow it did not create the controls, that is what was so strange. But we did use alot of Java code and not any delegates. That have been fixed now, but if you read my other post you see my new annoying error. One step forward two step backwards!
|
|
|
|
|
Ok, walking away from java threads and into delegates and threads. Anyhow would work better in theory I guess.
But even though I follow this: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vjsharp/html/vjwlkwalkthroughauthoringsimplemultithreadedcomponentwithvisualj.asp guide more or less exact, I get errors.
VS.NET refuses to use System.Delegate.Combine(eventHandler, eventHandler):
public delegate void FactorialCompleteHandler(double Factorial, double TotalCalculations);<br />
<br />
public FactorialCompleteHandler FactorialComplete;<br />
<br />
public void add_FactorialComplete(FactorialCompleteHandler e)<br />
{<br />
FactorialComplete = (FactorialCompleteHandler) System.Delegate.Combine(this.FactorialComplete, e);<br />
}<br />
<br />
That is all of the relevant code from the walkthrough but for some reason it wont work. Gets a:
Cannot find method 'Combine(objectHandler, objectHandler)' in 'System.Delegate'
|
|
|
|
|
Funny... I don't see you defining a Combine method in any of your code there...
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
But that one already exists in System.Delegate right?
Atleast it shows up when I type the . after Delegate, and I follow the constructor(two of them and I use the one with two eventHandlers).
Oh well, hungover and forced to code due to deadline. Life sucks
|
|
|
|
|
Cenatar wrote:
Oh well, hungover and forced to code due to deadline. Life sucks
Whoa... Dude... A little 'Chaser' next time! Deadlines! Remember?!
I should have gone back and read the sample code with both eyes open! Hmmm...
OK. This may seem stupid, but did you put this at the top of the code?
import System.*
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|