|
Why don't you handle the Validating event?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hmm, apart from checking the whole textbox everytime the user changes anything, i could get the text from the clipboard, and compare it to the textbox, if i find it matches, then they just pasted it in and i check the string for invalid characters.
It'd be a little more complicated that that of course.
I could also override the paste message, and do something there. But that would require even more messing around.
|
|
|
|
|
Have you looked at using a "MaskedTextBox"?
Phil
|
|
|
|
|
No, but i sorted it now. Perhaps next time.
|
|
|
|
|
Any reason you can't just validate the TextBox when the LostFocus event fires?
This allows the user to catch their own mistakes and fix them without causing the validation code to run needlessly. They haven't really "finished" until they shift focus elsewhere, so let them freely edit the text and simply validate it when they are "done".
|
|
|
|
|
I recently deployed an application I built on a client's server. When I wrote and tested this app on my machine (Celeron 2.8GHz 1GB ram), it took most of the processor power and tons of ram. Now that it is on the production server(4 processor 2.0 GHz 2GB ram), it takes less total ram then on my machine and only about 4% processor power. With all that being said it doesn't run any faster than it did on my machine... Any ideas on why the app just take up more resources and run faster? I did check the task manager and saw that none of the 4 processors were taking more than 10% or so on the server.
I know that I didn't give any info on the app itself, but I'm more curious about the theory at this point.
Thanks!
Hogan
|
|
|
|
|
Often performance issues have more to do with Database stuff then with the app itself. I would guess this might be the common thread between running it locally and on the production server. If some indexes need to be created on tables etc on the database to speed the app up it would affect both the prod server and your local box.
Hope that helps.
Ben
|
|
|
|
|
Ben,
Thanks for your idea, but I don't think that is it. In both instances, I am running the Microsoft SQL Server on the same box the app is running on. Any other ideas?
Hogan
|
|
|
|
|
I guess I would need a little more info. I am guessing this is a windows app? windows service? When you ran it on your box where you running via Visual studio? Or were you just running it via launching the exe. If you were running via VS that would take more memory. I am guessing that is not the case.
As far as why it uses less memory on your prod server, it might be because you are running sql server on the prod server. Sql server will more or less say this memory is mine you can't touch it. So you app might have used up more memory if it was allowed to.
So the fact that your app uses so much memory leads me to think that it is probably using virtual memory for what ever process you are running. So that means it is using hard disk space to page its ram memory. If you are using so much memory you start paging to disk like that, it can slow down a process.
Perhaps you are serializing large objects. I have found it is better to write the large objects to disk and clean up the files later, instead of just using RAM memory.
If you are using serialization stuff in sql server that is also slow especially the larger the serialize objects get.
Really it is hard to guess past that with out knowing more details of what you app is doing.
So there are a couple of stabs in the dark. Hope it helps.
Ben
|
|
|
|
|
Hi,
from the little you told us, I've got a feeling your app contains a busy loop
(i.e. a loop checking for something without including a delay such as Thread.Sleep)
and this loop runs many many cycles on a single-threaded CPU, whereas it gets statisfied
rather soon on a hyperthreading/multi-processor system. On the single-threaded CPU
Windows would assign most CPU cycles to the thread with the busy loop, and only few
are devoted to the next one or two ready threads; having more threading hardware would
give this/those other threads more opportunity to run, hence significantly reduce
the number of busy loop iterations.
If this is right, you should
1. look for the busy loop (might be as simple as while(someBool) {} )
2. and at least insert a delay in there, say Thread.Sleep(50)
which turns it into a polling loop (it no longer is a busy loop since it sleeps most of the time)
3. or better yet find a way to completely avoid the loop. The most appropriate way
would be to get the required synchronisation based on an event.
Hope this helps.
|
|
|
|
|
I have a database powered Windows application that uses Crystal Reports. Instead of loading a report that displays, say a list of all books that have been checked out, I would like the user to select the book title and then display the customized report. I have been reading a lot on discrete parameters, but I am unable to figure it out for some reason.
<br />
protected void SetParameterFields ()<br />
{<br />
ParameterFields paramFields = this.crystalReportViewer1.ParameterFieldInfo;<br />
ParameterField paramField = new ParameterField();<br />
paramField.Name = "book_name";<br />
ParameterValues curValues = paramField.CurrentValues;<br />
ParameterDiscreteValue discreteValue = new ParameterDiscreteValue();<br />
discreteValue.Value = "Huck Finn";<br />
curValues.Add(discreteValue);<br />
this.crystalReportViewer1.ParameterFieldInfo = paramFields;<br />
}<br />
<br />
Here "book_name" is a column in my database table.
When I display the report all records are displayed, not ones pertaining to Huck Finn.
What am I doing wrong and how do I correct it so I can get it to do what I need it to?
Thanks!
|
|
|
|
|
I can send a variable from Program.cs to Form1.cs by
Application.Run(new Form1(mode,fname));
How do I send a variable from Form1.cs to Program.cs
|
|
|
|
|
public string varForm1="Form1";
on form2 use value of variable varForm1
string varForm2 = varForm1;
I Love SQL
|
|
|
|
|
The method used depends on the intended use of the variable. If a certain action is to take place each time the variable changes, events are the way to go. However, if the variable is one that only needs to be checked once in a while, then you could use a read only property.
Phil
|
|
|
|
|
I have three buttons which set an integer called retInt in form1. In progam.cs I want to exit the program with return retInt;
Under vis2003 this was not a problem as I just declared static int retInt and it was seen in Main() and form1. Now that Main() is in program.cs and the buttons are in form1() I cannot pass the value of retInt from form1 to program.cs.
Forgive my stupidity but in C++ I would just declare a global variable and be done.
|
|
|
|
|
Sounds like the read only property is the way to go. Look up "Properties" in your help to see how they can be done. If you don't like properties, you could use a public static variable.
Phil
|
|
|
|
|
how i do code when i need a list of layers for each shape in order not to inference the other
|
|
|
|
|
I don't understand the question. What's a layer? What's a shape? Is this some sort of paint program?
More details please.
|
|
|
|
|
Hello,
im writting client/server application. I must create protocol to comunication between it. How it should look?
I thinging about something like that:
Class with data --> serialization --> Compression -->Encryption--> Sending
Receiving -->Decrypting --> Decompression - Deserialization
Is this good idea?
Greetings
|
|
|
|
|
That isn't a protocol. It is a description of dataflow between data transformation processes.
Other than that, it seems fine.
|
|
|
|
|
That architecture is going to take some time to send/receive. Does your serialization have to be compressed and encrypted?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Yup, it must be compressed and encypted... Data are very sensitive, and there is a lot of it. Getting history for one user - 10k records takes something about 16Mbytes after serialization. When its compressed it takes only 400kbytes. System will be huge - something about 10k users.
Will be two types of clinet:
- which will send data to server, then server store it in database - 99% of users.
- which retrive and analyze data from server - 1% of users
|
|
|
|
|
And don't worry about the details. Also, web services can be configured to be compressed and binary as well.
File Not Found
|
|
|
|
|
class P
{
public void foo1()
{
Console.WriteLine("Inside class AA method foo1");
}
public void foo2()
{
Console.WriteLine("Inside class AA method foo2");
}
}
I can use the methods of this class "P" two way !!!!
1. I can inherit in a derived class like this way
class Q:P
{
}
Q q = new Q();
q.foo1();
q.foo2();
2. I can take an instance of class P in some class and I can expose the object of class P using some property ....
class R
{
P aa = new P();
public P Prop
{
get
{
return this.aa;
}
}
}
R r = new R();
r.Prop.foo1();
r.Prop.foo2();
My question is what is the pros and cons of this kind of method accessing technique!!!
When to use which one ?? Is there any difference between these two ???
Thanks,
Arindam D Tewary
|
|
|
|
|
Hi
I think there's no much difference. It is a type of organizing the code like parent child relation ship. Both method can access the public members. But using inheritance method will give a clear hierarchy of the program.
public class parent
{
//methods
}
public class child:parent
{
//methods
}
I think this will give a clear picture that child having parent properties.
|
|
|
|