|
S. Senthil Kumar wrote: I've seen the exception thrown when you are calling BeginInvoke on a control that has been instantiated but has not yet become visible. .NET 2.0 apparently creates the backing Win32 handle lazily, when the control is about to become visible for the first time, and if you happen to call Invoke/BeginInvoke before it, it fails with that error.
This sounds very promising as the controls are indeed hidden -- do you know if this bug applies to .NET 3.5?
Cheers,
Greg
|
|
|
|
|
Hi I have just started learning C#
I have installed Visual studio 2005
when I tried to run a C# program,got an error csc is not recognised
I dont know what to do
I tried to google it
got response To fix this problem, execute the batch file corvars.bat located
in the bin directory of the SDK. Change directories to the Framework
SDK root directory, normally installed in the directory \Program Files\
Microsoft.NET\FrameworkSDK\bin. Execute the batch file by typing
corvars on the command line. Now change directories back to where
your program is saved and compilation should be successful
i tried my best but no result
Plz help
Regards
Kuldeep
|
|
|
|
|
Use the visual studio command prompt and not the regular command prompt.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
From where you are executing Csc Command ?
Best Regards
-----------------
Abhijit Jana
"Success is Journey it's not a destination"
|
|
|
|
|
Hello
I've made tho following function in a form to avoid to open severall instance a child form dialog
It works fine but I do'nt know how to check if the user ave close the form from itself!
Because in such situation FrmZTour remain not null and I got an error !
private void ShowForm(DataTable dtDagChauff)<br />
{<br />
if (FrmZTour == null )<br />
{<br />
FrmZTour = new FrmDgvZoomTour();<br />
FrmZTour.SelectTour += new FrmDgvZoomTour.SelectTourHandler(DgvTourSelected);<br />
FrmZTour.Show(this);<br />
}<br />
<br />
FrmZTour.FillDgv(dtDagChauff);<br />
}
|
|
|
|
|
EDIT: Forget that, apparently you can't re-show a form after its closed. But i did find the solution, the form should have an IsDisposed property, so you need to check that as well:
if(FrmZTour == null || FrmZTour.IsDisposed)
That should sort it out.
My current favourite word is: Bacon!
-SK Genius
Game Programming articles start - here[ ^]-
modified on Monday, May 12, 2008 8:28 PM
|
|
|
|
|
Thank you
Finaly I did adapt your first sugestion
<br />
private void ShowForm(DataTable dtDagChauff)<br />
{<br />
if (FrmZTour == null )<br />
{<br />
FrmZTour = new FrmDgvZoomTour();<br />
FrmZTour.SelectTour += new FrmDgvZoomTour.SelectTourHandler(DgvTourSelected);<br />
FrmZTour.Closed += new EventHandler(this.formClosed);<br />
FrmZTour.Show(this);<br />
}<br />
<br />
FrmZTour.FillDgv(dtDagChauff);<br />
}<br />
private void formClosed(object sender, EventArgs e)<br />
{<br />
FrmZTour.Dispose();<br />
FrmZTour = null;<br />
}
|
|
|
|
|
It has a Visible property.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I'm trying to build a high performance windows application that does basic calculations on many different data sets. Can anyone explain to me why this always returns false???
int[] x = new int[10] { 10015, 10, 9, 8, 7, 6, 5, 4, 2, 2 };
int[] y = new int[10] { 10015, 10, 9, 8, 7, 6, 5, 4, 3, 2 };
if (x.Equals(y)) return true;
else return false;
I'm pretty sure that .Equals is comparing the ADDRESS of the two arrays, as opposed to the values. Can someone help me out on what the fastest way of comparing these arrays?? no looping is HIGHLY preferred.
|
|
|
|
|
shamidi wrote: no looping is HIGHLY preferred.
Depends on what level you want that to occur on. Using LINQ there's no "looping" on the surface but it'll translate into a loop.
You have to face facts, you've got an array of data, you have to loop to do anything useful with it.
In response to your first point, Equals is comparing the addresses but because you're initialising them independently they are in fact in two different blocks of memory, thus not the same.
It would return true (I think) if you did:
int[] x = new int[10] { ... };
int[] y = x;
return x.Equals(y);
See that last line? What you've just done there is a coding horror (check the forums), your comparing a bool to return a bool You can simplify the code (and the resulting assembler) by doing what I did.
I doubt it. If it isn't intuitive then we need to fix it. - Chris Maunder
|
|
|
|
|
Ed.Poore wrote: See that last line? What you've just done there is a coding horror (check the forums), your comparing a bool to return a bool [WTF] You can simplify the code (and the resulting assembler) by doing what I did.
Sorry about that....wrote a quick snippet to get posted.
The reality is that this a small piece of a huge block of code that isn't working because of this reference issue.
int[] x = new int[10] { ... };
int[] y = x;
this doesn't help me a lot, seeing as how the two int[] arrays that I'm trying to compare are created in two separate areas of the code...I need to see if the result of both methods are the same, and if they are, ignore one of them. The arrays int[] arrays look exactly as those that I wrote in my previous post.
Is there another data type that you can think of to use to resolve this? Or am I screwed into looping? The looping is killing me on performance.
|
|
|
|
|
First question are both guaranteed to be the same length?
Secondly how do you mean equal, both have the same values in the same positions or simply contain the same integers but in different locations?
If 1 is false and 2 implies both in the same order and value then the fastest way would be:
if (x.Length != y.Length)
return false;
for (int i = 0; i < x.Length; i++)
{
if (x[i] != y[i])
return false;
}
return true
This code will work based on the fact that they are equal under the condition that both arrays have the same values at the same indicies. Obviously you could tailor this algorithm slightly because if you know differing values are likely to occur at the end of the array then you can loop backwards thus hitting the difference first.
You will have to loop regardless, even if you went down to assembly then the processors will only be able to handle a maximum (I think) of a 64-bit bitwise operation (if you're lucky) so they will have to loop anyway.
If you're still having issues with performance, is your code running on a multicore processor? If so and you still want to go through C# (note I have seen some statistics where C# can out perform C++ but for the life of me I can't remember which areas they are, so you might as well stick with it); anyway if you are running on a multicore then you might want to take a look at the Parallel Extensions for .NET[^]. Which can through a "simple" syntax optimise your loops to run on multicore processors (or leave it alone for single cores).
I doubt it. If it isn't intuitive then we need to fix it. - Chris Maunder
|
|
|
|
|
I'm pretty sure that all of the VS versions come with a debugger. Ever thought of trying it?
As far as the comparison is concerned, you have to give us more info - do the arrays only match if it contains the same set of numbers? Does it only match if all of the elements are in the same order? Are both arrays always going to be the same size?
It looks like a loop is your only viable choice of testing for equality. Here's one approach given the array and the order of elements specified:
bool matches = true;
for (int i = 0; i < x.Length; i++)
{
matches = (((x[i] + y[i]) % 2) == 0);
if (!matches)
{
break;
}
}
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: I'm pretty sure that all of the VS versions come with a debugger. Ever thought of trying it?
Debugger? Weird...I'll MSDN it, must've slept through that day of programming school.
Thanks for the snippet.
|
|
|
|
|
What about:
bool matches = true;
for(int i=0; i<x.Length; i++) {
matches = ( (x[i]&y[i]) == x[i] );
if(!matches)
break;
}
EDIT: Then again if x[i] = 00001111, and y[i] = 11111111. Then x[i]&y[i] = 00001111. But still.
Binary operators should be faster right? Although, whats wrong with plain old if(x[i] == y[i]) ?
My current favourite word is: Bacon!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
You can't apply & or | to integer values like that, so I guess that would make them slower.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
shamidi wrote: no looping is HIGHLY preferred.
You can use recursion instead. Here's a pretty ugly implementation:
public bool ArrayCompare(int[] a, int[] b, int offset) {
return a.Length != b.Length ? false : (offset == a.Length ? true : (a[offset] != b[offset] ? false : ArrayCompare(a, b, offset + 1)));
}
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
This is much less time and memory efficient than a simple for loop.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: This is much less time and memory efficient than a simple for loop.
But it's just one line of code. It has to be fast.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
Am getting the value of a node from my XML like this..
XmlDocument doc = new XmlDocument();
doc.Load(Application.StartupPath + "\\XMLfile.xml");
string xpath = "/Image/Crop/X";
XmlNode ReadX = doc.SelectSingleNode(xpath);
XmlNode X = ReadX.FirstChild.ParentNode;
XmlNodeReader nodeReader = new XmlNodeReader(X);
X = doc.ReadNode(nodeReader);
(Is this right? As I am new to .Net..I req u to check out and If am wrong.. kindly correct my mistake)
And if am right..
I want to use this X as an integer.. How do I do this...
I tried a method..But it throws an error that "Cannot implicitly convert type Int to system.xml.xmlnode"..tell me a way to retrieve the value of a node from my xml and to use in my further part of my program.. as an integer..
Thank You!
|
|
|
|
|
One of the nice benefits of the built in .NET xml serialization is that you can create an object decorated with attributes and then use the XML Serializer object to directly read all of the file with little or no word. I would like into it a bit.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
Thanks for the response Sir,my reqst is..
Suppose i declare an integer called XP and now i want to assign the value of X(from previous coding) with XP. How do i convert it?
|
|
|
|
|
Shan85 wrote: string xpath = "/Image/Crop/X";
Shan85 wrote: I want to use this X as an integer.. How do I do this...
The letter 'X' is not an integer.
Say your XML looks like this:
<Image><Crop><X>22</X></Crop></Image>
Then, and this is certainly not the only way, without accounting for possible errors:
XmlDocument doc = new XmlDocument();
doc.LoadXml("<Image><Crop><X>22</X></Crop></Image>");
XmlNode node = doc.SelectSingleNode("//Image/Crop/X");
int val = int.Parse(node.InnerText);
System.Diagnostics.Debug.WriteLine(string.Format("X+1 = {0}", val + 1));
led mike
|
|
|
|
|
Great Job Mr.Mike..
A single line of code is enough..Littl confused now.
Like.... int XP = somthing.Convert.toint32(X)
u said that x is not an integer,.. But i want to use this node value as an integer in my next part of my program.. is t possib?
|
|
|
|