|
psdavis wrote:
I am calling a DLL function from my C# application, but when the application is executed, it takes approximately 5 seconds to complete it.
Its normal for any .NET language to have a delay at application start.
psdavis wrote:
But if I throw a breakpoint before the call, and step thru it, the function runs in only 1 second?!?
Weird? Can you please supply me some more details, what function are you calling and the implementation?
psdavis wrote:
I am letting it run 10 times with and without break points, and it stays consistent.
More details, you dont state how you loop it? I hope you are not just restarting the application everytime, if so refer to above
psdavis wrote:
This is sooo backwards from what I was expecting. Any ideas on why breaking to debug mode speeds up the process!?
My only debug problems is , that when stopping at a breakpoint and trying to step thru the lines (in rare cases i might add), that the application just freezes.
Give them a chance! Do it for the kittens, dear God, the kittens!
|
|
|
|
|
leppie wrote
Its normal for any .NET language to have a delay at application start.
/nod, but this is in response to a menu item being selected.
leppie wrote
Weird? Can you please supply me some more details, what function are you calling and the implementation?
Unfortunately, it is an outside library that opens up a file in a specific format. I've used this library for a good 5 years though, and it's always run in under a second.
But basically, I'm doing a 'select file', 'open file' when a menu option is selected.
leppie wrote
More details, you dont state how you loop it? I hope you are not just restarting the application everytime, if so refer to above
Nah, just clicking 'File-Open' again with different file names each time. I've run the test around 20 times now, with mix and matches of the files and it's extremely consistent.
|
|
|
|
|
Little more info...
It's OpenFileDialog causing the slowdown!!!?
private void menuItem7_Click_1(object sender, System.EventArgs e)
{
OpenFileDialog pFileOpen = new OpenFileDialog( );
pFileOpen.InitialDirectory = @"J:\Aware\SPECS\EFTS\6.2\Samples\10_subs";
pFileOpen.Filter = "EFTS Files (*.eft)|*.eft|All files (*.*)|*.*";
pFileOpen.FilterIndex = 1;
if( pFileOpen.ShowDialog( ) != DialogResult.OK )
return;
EFTS.EftsFile pEftsFile = EftsVerification.LoadEftsFile( pFileOpen.FileName );
Classification.Classify pDialog = new Classification.Classify( );
pDialog.EftsFile = pEftsFile;
pDialog.ShowDialog( this );
}
If I comment out the OpenFileDialog part of the code and give the LoadEftsFile the name of the file directly, then it loads normal and quick.
Seems that OpenFileDialog is doing some sort of 4 second clean up?!?
|
|
|
|
|
For this test, I created a new dialog that allowed you to type the name of the file.
I then replaced OpenFileDialog with TestFileDialog and left the rest of the code exactly the same.
OpenFileDialog - 4 seconds
TestFileDialog - 1 second
There is something seriously wrong with that function.
|
|
|
|
|
Hmm, drive J:, a network drive. If so, Windows is taking its time looking for all the pretty icons for the files in the FileDialogBox seriously! Try to set to list or details view...
I never had problems with that though...
Give them a chance! Do it for the kittens, dear God, the kittens!
|
|
|
|
|
Thanks Leppie, but the 3 second differential is after it closes, not while it's loading the icons. Also tried it on the local drive.
Now get this!! OpenFileDialog seems to be keeping the file that you selected busy for 3 seconds or so after you click 'ok'!!
EFTS.EftsFile pEftsFile = EftsVerification.LoadEftsFile( @"J:\Aware\Specs\EFTS\6.2\samples\10_subs\car2.eft" );
Here I manually override the Load to load a specific file. If I select a different file car3 , then we're back to one second. If I select the 'same' file car2 , then it's back to 4 seconds again.
|
|
|
|
|
if( pFileOpen.ShowDialog( ) != DialogResult.OK )
return;
Stream myStream = pFileOpen.OpenFile( );
if( myStream != null )
myStream.Close( );
EFTS.EftsFile pEftsFile = EftsVerification.LoadEftsFile( pFileOpen.FileName );
GRRrrrr!!! I tried this on a hunch. Once I select my file, then I open it up and immediately close it. The time is EXACTLY the same, but just in different order. The OpenFile/Close takes about 2-1/2 seconds and my LoadEftsFile is back to normal again.
Is OpenFileDialog trying to open up my file?!
|
|
|
|
|
psdavis wrote:
If I select a different file car3, then we're back to one second. If I select the 'same' file car2, then it's back to 4 seconds again.
So its file related? How does the size differ?
CheckFileExists Overridden. Gets or sets a value indicating whether the dialog box displays a warning if the user specifies a file name that does not exist.
CheckPathExists (inherited from FileDialog) Gets or sets a value indicating whether the dialog box displays a warning if the user specifies a path that does not exist.
Try disabling both these... This about as much as I can help Brain is starved now.
Give them a chance! Do it for the kittens, dear God, the kittens!
|
|
|
|
|
> So its file related? How does the size differ?
Copy of the original file.
> CheckFileExists & CheckPathExists
Way ahead of you bro. No change.
I guess I'm going to have to recreate the OpenFileDialog until they fix the bug. Unfortunately, they don't even have any problems reported with OpenFileDialog reported on their knowledgebase, nor do I have a couple of hundred bucks burning a hole in my pocket to report it.
Anyone know of a OpenFileDialog replacement control?
|
|
|
|
|
It definitely has something to do with it being on a networked drive.
If I move the entire directory over to my local drive, the 5 second load now becomes 1/4 second.
I'd say that it was only a problem with my network, if I couldn't replace OpenFileDialog with my own dialog and reduce the time so greatly. OpenFileDialog must be trying to verify something about the file by opening it, and with my slow network, I'm really seeing the effects of it.
|
|
|
|
|
Or.....
Maybe that file you are opening needs reources from the network drive and that is taking so long....
Give them a chance! Do it for the kittens, dear God, the kittens!
As seen on MS File Transfer: Please enter an integer between 1 and 2.
|
|
|
|
|
You know... application settings in ini/registry.
IOW I heed something like in MFC GetProfileString etc.
|
|
|
|
|
I think RegistryKey class is what you want.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Yeah but that's too complicated, compared to GetProfileString(MFC) or GetSetting(VB). I was lazy to dig into RegistryKey.
|
|
|
|
|
inner wrote:
but that's too complicated, compared to GetProfileString(MFC) or GetSetting(VB).
Oh man,its really easier than MFC way I think.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
I wonder if someone has solved this little problem:
Situation:
1) A data grid is bound to a dataset containing one datatable. There is no backend database connection, the datatable is populated programmatically.
2) At runtime, the user highlights a row in the grid and presses the delete key, intending to delete the row of data.
Now the problem, of course, is that the data isn't really gone. It's still in the datatable. But how do I update the table? A seemingly simple answer is to add a OnRowChangedEvent hander and call AcceptChanges()
protected void OnRowChanged(object sender, DataRowChangeEventArgs args)<br />
{<br />
dataTable1.AcceptChanges();<br />
}
but this generates a stack overflow. Does anyone have an idea what I should really be doing?
Thanks!
|
|
|
|
|
Doug Brower wrote:
At runtime, the user highlights a row in the grid and presses the delete key, intending to delete the row of data.
Now the problem, of course, is that the data isn't really gone. It's still in the datatable. But how do I update the table? A seemingly simple answer is to add a OnRowChangedEvent hander and call AcceptChanges()
protected void OnRowChanged(object sender, DataRowChangeEventArgs args)
{
dataTable1.AcceptChanges();
}
Hi
Override the OnRowDeleted function, and remember to call base.OnRowDeleted(sender, args) after calling your functions. Also have a look at DataTable.GetChanges().
Hope this helps
Give them a chance! Do it for the kittens, dear God, the kittens!
|
|
|
|
|
Thanks for the suggestion, and quick response!!
|
|
|
|
|
Hi,
I am looking for a good book or reference about multithrad programming (Thread.Pool...) in C#. Your help is appreciated!
|
|
|
|
|
Hi
Have a look at the following.
http://www.gotdotnet.com/userfiles/toub/ManagedThreadPool.zip[^]
From the readme.txt:
Stephen Toub
stoub@microsoft.com
ManagedThreadPool.cs
August 27th, 2002
v1.0.1
Thread pool class written in C#. Mimics the core functionality of
the System.Threading.ThreadPool class. Useful when using System.Net
functionality in callback delegates.
I must say this guy has written some of the best code I have seen in C#. Although I havent looked at the above library, expect the code to be of high standard
Hope this helps
Give them a chance! Do it for the kittens, dear God, the kittens!
|
|
|
|
|
Thank you, Leppie.
|
|
|
|
|
What is the best way to specify the application path in C#? In VB we could use App.Path . I am trying to specify the following connection string and it is drawing a line underneath it so I know it doesn't like the way I have declared it.
string myConnString = "Provider=SQLOLEDB;Data Source="C:\Documents and Settings\User\Desktop\phonebook\phonebook.mdb";" +
"Initial Catalog=phonebook;Integrated Security=SSPI;" +
"Connect Timeout=30";
I have also tried
string myConnString = "Provider=SQLOLEDB;Data Source=@"C:\Documents and Settings\User\Desktop\phonebook\phonebook.mdb";" +
"Initial Catalog=phonebook;Integrated Security=SSPI;" +
"Connect Timeout=30";
Nick Parker
The goal of Computer Science is to build something that will last at least until we've finished building it. - Unknown
|
|
|
|
|
Hi Nick, note the escapes, else the string will end You can AFIAK substitute "\" for "/" in paths. I ussually find it easier to drop a DBConnection on the form, then setup connection string via wizard. Then just copy and paste it to a const string.
string myConnString = "Provider=SQLOLEDB;Data Source=\"C:/Documents and Settings/User/Desktop/phonebook/phonebook.mdb\";" +
"Initial Catalog=phonebook;Integrated Security=SSPI;" +
"Connect Timeout=30";
Hope this helps
Give them a chance! Do it for the kittens, dear God, the kittens!
|
|
|
|
|
Thanks leppie,
I actually ended up using the quoted string literal (i.e. - @ ) so it was a little cleaner, however I had the snytax a little messed up this morning. It now looks like this:
string myConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + @"C:\Documents and Settings\User\Desktop\phonebook\phonebook.mdb";
Thanks
Nick Parker
The goal of Computer Science is to build something that will last at least until we've finished building it. - Unknown
|
|
|
|
|
I would like to know how i can play a wave file through TAPI. My requirement is to hook up to a telephone number through a Modem and when the connection is successful, the application should play a wave file.
There is no adequate support provided in .NET frame work for Telephonic applications.
Can some one help please.....
Harihara Subramanian
|
|
|
|