|
private void loadRegimes()
{
XmlDocument document=new XmlDocument();
document.Load(xmlRegimes);
XmlNodeReader reader=new XmlNodeReader(document);
int standno=0,age=0,polygonno=0;
double acres=0;
ArrayList regimesList; //holding regimes for each stand
ArrayList regimeList; //hold ac cf wf data of regimes, ac cf wf data
ArrayList regimeObjList;//hold objetive value of each regime
int flowtype=0, flow=0, period=0;
string temStr;
while (reader.Read())
{
switch(reader.NodeType)
{
case XmlNodeType.Element:
switch(reader.LocalName)
{
case "stand": //cr
............................
Because the xmlRegimes is very large, the program get stucked, Is there a better way to load large xml file?
Thanks
|
|
|
|
|
There is.
The trouble with this approach is that you are loading the whole file into an XmlDocument, which keeps the whole thing in memory. You are then parsing this memory copy using a forward only reader.
Where possible, its better to stream the Xml in using XmlTextReader, this also is a forward only reader, but by using this you only deal with a tiny chunk of the whole document at a time. This is much prefered server-side as if you have multiple threads in your server each loading large xml documents in you could end up with a stressed server. This solution is far more scalable.
Regards,
Rob Philpott.
|
|
|
|
|
I was wondering if someone could point me in the right direction for creating a web component to an existing site, where an administrator could send the user messages. This is similar to etrade.com 's alerts or ebay's user inbox.. thanks!
MRH
|
|
|
|
|
Hello everyone, I was wondering are there any functions in ASP.NET that will allow you to pause for a few seconds like a sleep or wait function.
Thanks
TheMajorRager
|
|
|
|
|
Do you mean paues on the client or the server? If you're talking about pausing on the server then Thread.Sleep() might be what you're looking for. I'm sure there is a javascript equivalent for the client as well.
Can you give us some more context as to what you are trying to achieve?
Jared Parsons
jaredp@beanseed.org
http://spaces.msn.com/members/jaredp/
|
|
|
|
|
TheMajorRager wrote: I was wondering are there any functions in ASP.NET that will allow you to pause for a few seconds like a sleep or wait function
Not in the ASP.NET framework per se*. However, in the .NET framework (of which ASP.NET is a subset) there is <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemthreadingthreadclasssleeptopic.asp" rel="nofollow">Thread.Sleep()</a>[<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemthreadingthreadclasssleeptopic.asp" target="_blank" rel="nofollow" title="New Window">^</a>]
* Sorry, just being pedantic
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
Why would you want the server to sleep in the middle of building an HTML page for the client??
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Do you want to wait for some external process - or for an internal process to complete. If the latter you will need to look at threading and suspending a thread until an event or trigger occurs.
|
|
|
|
|
I have written a user control for my application. This control is based on the listbox.
In the control, I have the listbox, and added a button and some labels to it
I want this control to act exactly like a normal listbox. I need the ChangedSelectedIndex event on it so that when i click on it in the main program it will do something. Oh, and also i want the button to work too, -- to have a MouseClick event.
How do i do that? I am very newbie to events and delegates, I am still very confused after reading a few articles. Can someone explain it to us
-- modified at 16:32 Thursday 1st December, 2005
|
|
|
|
|
2hdass wrote: I want this control to act exactly like a normal listbox. I need the ChangedSelectedIndex event on it so that when i click on it in the main program it will do something. Oh, and also i want the button to work too, -- to have a MouseClick event.
You have to bubble the events up. In the user control, wire up the SelectedIndexChanged event of your ListBox and the Click event of the Button to local event handlers like this:
namespace Test {
public class UserControl1 : System.Windows.Forms.UserControl {
public event EventHandler SelectedIndexChanged;
public event EventHandler ButtonClick;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Button button1;
public UserControl1() {
InitializeComponent();
this.listBox1.SelectedIndexChanged +=
new System.EventHandler(this.listBox1_SelectedIndexChanged);
this.button1.Click += new System.EventHandler(this.button1_Click);
}
private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e) {
if (this.SelectedIndexChanged != null)
this.SelectedIndexChanged(this, e);
}
private void button1_Click(object sender, System.EventArgs e) {
if (this.ButtonClick != null)
this.ButtonClick(this, e);
}
}
}
Now the consumers of your control can wire up the new user control events you've exposed, SelectedIndexChanged and ButtonClick , and receive notification of events to the controls that make up your user control.
Share and enjoy.
Sean
|
|
|
|
|
Hi:
The SortedList class has a couple of interesting methods GetKeyList() and GetValueList(). However the return tyope is IList and I found I couldn't do much with it.
When I know that the values are doubles, I would like to be able to get a double[] array. Is there a quick way (without using for/foreach) to extract the values from the sortedlist into a double[]?
Thanks, Sam
|
|
|
|
|
Yep, there's a way to do it:
double[] myArray;
SortedList myList;
[...].
myList.Values.CopyTo(myArray, 0);
The second parameter of the CopyTo method indicates the position inside myArray when the elements will start being copied.
Of course, its up to you to create an array big enough to store elements from the collection, and to check that casting from the collection elements to the array elements is consistent.
Hope this helped.
Nothing worth having comes easy.
|
|
|
|
|
Sweet! that works really conveniently.
Oh... and things worth having do come easy with the help of friends on Code Project.
Regards, Sam
|
|
|
|
|
How do I create a Custom DashStyle? I can't find it in MSDN help....
Thanks in advance......
|
|
|
|
|
Hi,
How do I detect the default email client by c# ?
And btw can I set the default email client at
the control panel of Win XP ?
Thanks
|
|
|
|
|
The default value for the registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail" contains the name of the sub-key that contains the information for the default mail client. For example, in my registry, I've got the following:
[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail]
@="Mozilla Thunderbird"
[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\Mozilla Thunderbird]
... and more ... As you can see, my default mail client is "Mozilla Thunderbird" and the key HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\Mozilla Thunderbird contains the settings.
This article may help: ARTICLE.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hi
I have LDAP provider that retrieves the users from Active Directory. However, how can I get the groups for each of the user that I retrieve? It's probably not the place to ask the question, but I do it on SQL Server by running ActiveX script. Any ideas?
Thank you.
|
|
|
|
|
|
Hi all.I want to update my UI via a background thread.
I have concluded in two options :
1.) Checking InvokeRequired
private delegate void UpdateUIHandler();
...
protected virtual void UpdateUI1()
{
if(!InvokeRequired)
{
...
}
else
{
this.Invoke(new UpdateUIHandler(UpdateUI1));
}
}
2.) Using an anonymous method and MethodInvoker:
...
public void SomeMethodRunningInDiffirentThread()
{
...
this.Invoke(new MethodInvoker(
delegate()
{
UpdateUI2();
}
));
...
}
public void UpdateUI2(){...}
So the question is the following.Which approach is more suitable?Are there any deficiencies or side-effects in any of these two methods (e.g performance,stupidity etc.) or any conceptual error in the approaches.
Thanx in advance.
|
|
|
|
|
Well, the second way is more verbose, as you need two methods to do the job. You also left out the check for InvokeRequired in the second method. It's not a mistake, as Invoke internally checks if it's on the UI thread before doing the actual job.
I'd say both are equivalent, but you'd want to prefer the first.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thanx for answering.In the second method i have intentionally left out InvokeRequired check.
|
|
|
|
|
You can also shorten up the second one a bit. It avoids the overhead of an extra object creation and delegate call.
2.) Using an anonymous method and MethodInvoker:
...
public void SomeMethodRunningInDiffirentThread()
{
...
this.Invoke((MethodInvoker)delegate()
{
UpdateUI2();
}
));
...
}
Jared Parsons
jaredp@beanseed.org
http://spaces.msn.com/members/jaredp/
|
|
|
|
|
Hi;
I'm french which does not know a lot about Add-ins...
I did a COM Add-ins for outlook in C# through VS .NET.
I add a configuration file in my project to set some specifics configurations.
I add a project for setup (which build a .msi file). This one copy the configuration file in the installation directory of the add-ins.
I tried to get information with the method :
String dataReadFromConfigFile = ConfigurationSettings.AppSettings["MyKeyToData"];
But it does not read my configuration file. In fact I think that it reads Outlook one.
So my question is :
How to read the configuration file in the installation directory of my add-ins ?
This question can simplified in :
How to get directory of the installation of my add-ins ? And then it can be read easyly by reading a .xml file.
Many thanks for Help
Frédéric
Frédéric
|
|
|
|
|
How to copy file from a server to the other when other server is in different domain!!!!
|
|
|
|
|
Use the full domain name in the UNC path.
When I'm at work I can copy a file from a path like this:
\\SomeServer\SomeShared\FileName.txt
When I connect from another domain I can use
\\SomeServer.MyCompanyName.co.uk\SomeShare\FileName.txt
Also, we have situations where there is some configuration in the Active Directory (some trust setting, I'm not the Sys Admin so I don't really know) where by different domains are given trust so that I can log on with my regular username/passphrase combination.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|