|
I put the wrong code in the post. This is what I was thinking about:
it works:
int[] values1 = new int[1024*1024*50]
int[] values2 = new int[1024*1024*50]
it gives OutOfMemoryException:
int[] values1 = new int[1024*1024*100]
There is enough free memory to allocate even 1Gb, but the problem for .NET is that there is no continous area of the memory which size is 400Mb. This is why I can allocate two times 200Mb but I can not allocate 400 Mb once. The question is: Can it be avoided somehow?
pawelpus
|
|
|
|
|
I would like to make an exe dependent on another exe i.e when program a.exe is started program b.exe should also start and when program a.exe terminates program b.exe should also terminate.
Is that possible?
How could I make it happen?
|
|
|
|
|
On Load form of ur a.exe programm start b.exe program
On Close from of ur a.exe programm kill process of b.exe program
|
|
|
|
|
when program A starts, it could create a System.Diagnostics.Process object at startup and start the other programm. Since programs sometimes doesn't shut down when and as they were meant to, there is no guarantee that the "cleanup" code will get executed so the answer to your question would be yes and no...
|
|
|
|
|
Hi All,
I have a DataTable in cache object and a local Datatable populated by calling an SP. I need to compare the whole data in both DataTables.If Cache DataTable's data is old then refresh it with latest one by calling the SP again and then use it later on.
How can I achieve this ?
Pls guide me.
Thanks
Omkar
|
|
|
|
|
You also posted this in the SQL message boards. Please do not cross-post.
|
|
|
|
|
Hi I'm using the SerialPort class (.net 2.0) for rs232 communications. Unfortunately, an it freezes up my program when I try to set a parameter for it after it's been opened.
First I initialize the port:
SerialPort port = new SerialPort(comname, 19200);
port.Open();
port.ReceivedBytesThreshold = 63;
port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
Then I do some communications stuff. So far so good. The freeze occurs when I try to use the port for some other process.
if (port.IsOpen)
{
port.DiscardInBuffer();
port.DiscardOutBuffer();
port.Close();
}
port.ReceivedBytesThreshold = 1;
port.Open();
Any of the commented line freeze up my program as if in a blocking state, and the code doesn't throw an exception of any kind, it just freezes each and any thread currently running. Does anyone have any clues what's happening here?
|
|
|
|
|
Ok, I already found the problem, for some strange reason the port needs to be reconstructed:
port = new SerialPort(port.PortName, port.Baudrate);
Weird...
|
|
|
|
|
Not Wierd. You'll actually find that this happens throughout the Framework. Try looking at the Font class for another example of immutable, or partially immutable, objects.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi All
I am trying to use
string searchPattern;
Directory.GetFiles(@"C:\myDirectory", searchPattern);
but I want to make my search pattern include certain types for example *.jpeg and *.htm and so on .....
How to implement this
|
|
|
|
|
if it works like the filter for openfiledialog it should be enough to pass a string like
"*.jpeg|*.htm|*.html" - if not you could easily write it by yourself.
<br />
searchpattern[0] = "*.jpeg";<br />
searchpattern[1] = "*.html";<br />
searchpattern[n] = ...;<br />
<br />
FileInfo filelist[n];<br />
<br />
<br />
for (int i = 0; i < searchpattern.GetLength(0) -1; i++)<br />
{<br />
filelist[i] = Directory.GetFiles("C:\WhatEver", searchpattern[i]);<br />
}<br />
<br />
Since I haven't had to do anything similar there may be a built-in function (for passing multiple searchpattern) i dont know of...
Good luck,
mik
|
|
|
|
|
GetFiles only works with one wildcard pattern. If you want to return varying patterns, like "*.jpg" and "*.bmp" you'll have to make seperate calls to GetFiles, one for each pattern you want to use.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
|
Here's something I coded up a few weeks ago:
public IEnumerable<string> GetFilesInDirectory(string directory, SearchOption searchOptions, params string[] filters)
{
foreach (string matchingFile in Directory.GetFiles(directory, "*.*", searchOptions))
{
if(EndsWithAny(matchingFile, filters))
{
yield return matchingFile;
}
}
}
bool EndsWithAny(string text, string[] endings)
{
foreach(string ending in endings)
{
if(text.EndsWith(ending))
{
return true;
}
}
return false;
}</string>
You can use it like this:
foreach(string jpgOrHtmFile in GetFilesInDirectory("c:\\myDir", SearchOption.AllDirectories, ".jpg", ".htm"))
{
Console.WriteLine(jpgOrHtmFile);
}
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Dumbest. Movie. Title. Evaaar.
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
many thx Judah
it works good
|
|
|
|
|
Hi
I have an SQL query which can be run in the Microsoft Visual C# 2005 Express Edition. But when I put that query in my program, it doesn't get run and it throws an exception saying "No given value for one or more required parameters".
Anybody knows how it could happen?
Thanks
|
|
|
|
|
printscreen12345 wrote: "No given value for one or more required parameters". Anybody knows how it could happen?
Just a guess, but I'd say you have parameters in your SQL statement that are not being set.
only two letters away from being an asset
|
|
|
|
|
it would be useful to:
- know the query
- know what you mean when talking about "my program"
did you ever read this "how to ask questions the smart way"-guide? :P
|
|
|
|
|
did you try to debug your application and then take the generated SQL query to execute directly on SQL Server or "Server Connections" in VS, for instance?
|
|
|
|
|
I was doing this
dt.Rows.Add(ds.Tables[0].Rows[1]);
Where dt is one table and ds.Tables[0] is another table. Now the
above statement throws up an error stating that "the row already
belongs to one table"
if i define an ArrayList
ArrayList al = new ArrayList()
and do
al.Add(ds.Tables[0].Rows[1])
this one works. Does any one know why the first one doesn't work
Probably the round about way is creating a new datarow and getting
the values from the ds.Tables[0] for that row and rebuilding the new row
for the dt table. But dont you guys think it make sense to directly copy the whole row from one datatable to another.
How do i do it.
Thanks
kal
|
|
|
|
|
The first one doesn't work because a DataRow may only belong to ONE and only one DataTable.
The second one works because an ArrayList is not a DataTable hence nobody cares about it.
It would make a lot of sense to copy the row from one table to another but what would happen if you change the values of the row in table A. the values would also be changed in table B because they're sharing a row. Maybe you want it to act like this but i wouldn't recommend trying it like this.
Instead you should do it as you've already mentioned and copy the important data from the row of table A to a NEW row of table B.
Good luck,
mik
|
|
|
|
|
I have a socket app. I have an event that is fired when the connection is closed. This event is caught stops my other two timers, and enables a 3rd timer, sets the timer interval and starts it. But it never happens, it never drops in to the tick event method. I have two other timers that are started from an event...like when the connection is up, they work fine. But it does not work when the connection is closed.
Not sure what code to post to help out as the event is in once class, the socket in another class, etc.
Why would a timer not fire on the tick event?
Thanks
Tom Wright
tawright915@gmail.com
|
|
|
|
|
you should try to get more information.
do you use an ide? if yes, which one and does it support breakpoints?! if so, use them.
make sure you see the line, where the timer is started, being executed.
also print out the values of the timer before it get started. compare the code of the other two timers and so on. before starting any timer, you should print its values to make sure its set up correctly. try to debug it because, as you already said, noone will know where to start searching.
|
|
|
|
|
yes I'm stepping thru my code (VS2003) and the interval is getting set. The timer is getting started. It's just never fired.
The last statement that is stepped thru is:
this.autoEvent.Set();
this is in the socket class. It is reseting my events when the socket is closed.
Then control is back at the interface...waiting for the timer to fire.
Tom Wright
tawright915@gmail.com
|
|
|
|
|
Question: can I make my timers avaliable in other classes...so that when the connection is closed, that class can start the timer, instead of me having to fire an event?
thanks
Tom Wright
tawright915@gmail.com
|
|
|
|