|
you don't need to kill any process. make two applications. one that creates a new desktop and then starts the second application (the kiosk one) within that newly created desktop. THAT's what you need right there. there are examples of this all over codeproject. it's easy to do, too. or you could just email me if you need help
|
|
|
|
|
dears,
I have a text file of about 800 MB 17,000,000 Lines and i have to process it line by line ..
i need a way to start more than one thread to read that file ...
the problem here is that i'm using the streamReader Class ...
the only available method for reading line is StreamReader.ReadLine().. "Sequential Access"
I need away to read a specific line directly... "Random Access"
this will give each thread the ability to read a part of that file
Any Idea .. Any Help ... is really appreciated ...
|
|
|
|
|
|
You could set up two stream readers and seek one of them to the middle of the file and have the second thread start from there. (It would have to move to the start of the next line to ensure it is in a good place). It might have the problem of thrashing the disk as it seeks between the two file locations.
You could have one thread tasked with just reading the file. And worker threads that process bits of the file. The worker threads each contain a queue which the first thread populates in a round robin. The worker threads pull data off their queues until the data processing is complete. (You would need to add a null to the queue to indicate that the end of the file has been reached)
|
|
|
|
|
Colin Angus Mackay wrote: You could set up two stream readers and seek one of them to the middle of the file and have the second thread start from there. (It would have to move to the start of the next line to ensure it is in a good place). It might have the problem of thrashing the disk as it seeks between the two file locations.
The only way I could see this not murdering performance was on a raid where each read thread was always targeting data from a different drive. Unless the data file is a fixed length format that aligns with the raids block size though I can't see any way to implement it.
--
If you view money as inherently evil, I view it as my duty to assist in making you more virtuous.
|
|
|
|
|
dan neely wrote: The only way I could see this not murdering performance was on a raid where each read thread was always targeting data from a different drive
That is why I said it would have the problem of thrashing the disk.
|
|
|
|
|
Hi,
you can use the Position property of streams to skip some of the data, so you could
start a few threads and give them different initial positions; I do have some remarks:
1. each thread will have to open the file in such a way that the others can also read it,
hence readonly and "shared reading"
2. if Position is not zero, the first line read will likely be a partial line, so you may
want to ignore the first line.
3. you will need a way to make each thread stop reading when it reaches the first valid
line another thread has already dealth with.
4. don't expect to gain much from large numbers of threads; two will probably help, and
four or more may well have a negative effect since overhead costs will increase
while the threads in the end may well compete for the same resources (unless processing
includes a lot of waiting on communications, or some other round-trip delays).
An alternative approach would be to have one thread that reads the entire file,
and dispatches the lines to a couple of threads for processing. This would be simpler
to organize, and maybe even better for performance, assuming your processing threads
don't need consecutive lines from the file.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
thanks all for your co-operation ...
but any code sample for the stream position Idea ... ??
Luc Pattyn wrote: you can use the Position property of streams to skip some of the data,
|
|
|
|
|
Sorry I don't have code available, I suggest you look at StreamReader.BaseStream and
Stream.Position
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
They have a library on MS Research to deal with big files and partial access.
xacc.ide
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."
|
|
|
|
|
FileStream allows random access. I used it to parse the national do not call database combined with binary search to access elements without parsing the entire file.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
hello, hello
i've encourted here some problem how to extract a table array.
one of the important things when u code an app is the daynamic Aspect.
well i'm trying to do this:
at the moment the app loads it self it load a dataBase without knowing what kind of tables are in the MDB file.
Well, i've been cracking my head using the GetSchema() Method
but it returns only one table, but nothing.
i've tried sql query Like "SELECT Name FROM MSysObjects"
But MSysObjects permisstion = false & still have not a way how to allow the
permisstion (maybe ADOX????) and nothing.
well any suggestion????
Have Fun
Never forget it
|
|
|
|
|
Try this one !!!
SELECT Name
FROM MSysObjects
WHERE Type In (1) AND Left([Name],4)<>"MSYS";
Happy Programming
-----
Abhijit
|
|
|
|
|
YEH
i've found that code from an SQL forum, and it's Version like :
"SELECT Name, Type FROM MSysObjectsWHERE Name Not Like 'MSys*' AND Type IN (1,6);"
but i'm still tring figure out how to solve the
NO Read Permission on 'MSysObjects' Odbc Exception!!!!
Have Fun
Never forget it
|
|
|
|
|
|
Changing your name and asking the same questions doesn't mean you are going to get a different answer!
The GetSchema method returns a DataTable where each row represents the information about each element in the database. You would use this information to create queries for each of the tables - if that is the purpose.
The fact is that there is no "magic" way of getting all of the information from a database because generally this is an AWFUL idea! I have no idea why you want to do this, but i suggest you rethink why you want to do this in the first place.
|
|
|
|
|
You can Change your Name But Your Problem will remain same !!!!!
Happy Programming
-----
Abhijit
|
|
|
|
|
I created a thread to which I passed two ThreadStart delegates to execute for me in the following manner.
ThreadStart myWorkerThread = (ThreadStart)Delegate.Combine(new ThreadStart(addListItemsToDisplay), new ThreadStart(checkProblematicValves));
Thread listThread = new Thread(myWorkerThread);
listThread.Start();
the delegate are:
public delegate void addListItemsHandler();
public delegate void checkProblematicValvesHendler();
the problem I encounter is that when executing the second function, it runs into an endless loop, only
of a reason related to the fact a different thread is running it, because if I run it from the main
thread, this doesn't occure, it simply leaves the function.
the function is:
private void checkProblematicValves()
{
foreach (long key in messageArr.Keys)
{
if (messageArr[key] != null)
{
for (int j = 0; j < messageArr[key].Count - 1; j++ )
{
if (messageArr[key][j] is Clusters.CSensorStatus)
{
if ((messageArr[key][j] as Clusters.CSensorStatus).valveAngDeg > 0)
{
string myKey = LongToHex(key);
int index = valveCheckedListBox.Items.IndexOf(myKey);
if (valveCheckedListBox.InvokeRequired)
{
checkProblematicValvesHendler d = new checkProblematicValvesHendler(checkProblematicValves);
valveCheckedListBox.Invoke(d);
}
valveCheckedListBox.SetItemChecked(index, true);
}
}
}
Thread.Sleep(50);
}
}
} //From here it returns to the start of the function for NO apparent reason.
Please help me!!!
thanks in advanced.
|
|
|
|
|
Hi,
First a comment: the line valveCheckedListBox.SetItemChecked(index, true);
should read else valveCheckedListBox.SetItemChecked(index, true);
since the SetItemChecked is not allowed by another thread.
AFAIK your thread will execute both methods once, one after the other.
The second method (checkProblematicValves) does contain an InvokeRequired/Invoke construct
which is intended to make it execute again on the thread that created valveCheckedListBox,
so yes this method may execute twice.
This construct is necessary because Controls are not thread-safe, so they should be
accessed only by the thread that created them.
Now the way you organized things is not optimal: you have several loops, and
it could happen that the InvokeRequired/Invoke construct fires multiple times,
each time causing the ENTIRE method to run again. I don't think that is what anyone would
intend.
The normal approach would be to organize the InvokeRequired/Invoke stuff outside
the first loop, hence put all the looping in the else part that I mentioned in
my first comment.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi Luc,
The second method (checkProblematicValves) does contain an InvokeRequired/Invoke construct<br />
which is intended to make it execute again on the thread that created valveCheckedListBox,<br />
so yes this method may execute twice.
I don't understand how exactly, Invoke() works, you got me confused.
Can you please explain to me how exactly it works, what do you mean by:
<br />
causing the ENTIRE method to run again
Is the following code what you meant???
private void checkProblematicValves()
{
if (valveCheckedListBox.InvokeRequired)
{
checkProblematicValvesHendler d = new checkProblematicValvesHendler(checkProblematicValves);
valveCheckedListBox.Invoke(d);
}
else
{
foreach (long key in messageArr.Keys)
{
if (messageArr[key] != null)
{
foreach (object message in messageArr[key])
{
if (message is Clusters.CSensorStatus)
{
if ((message as Clusters.CSensorStatus).valveAngDeg > 0 )
{
string myKey = LongToHex(key);
int index = valveCheckedListBox.Items.IndexOf(myKey);
valveCheckedListBox.SetItemChecked(index, true);
}
}
}
}
}
}
}
|
|
|
|
|
Hi,
I have not checked all the details, but it looks pretty close, yes.
How did you come to use InvokeRequired/Invoke without really understanding it?
I suggest you read some documentation on it if you feel the need to know more.
BTW: there is one optimization you might consider; if chances are nothing needs to be done,
then there is no need to do the Invoke stuff, so you might want to duplicate the looping
stuff in front of everything and rather than invoking itself or calling SetItemChecked, just
set a bool to true to indicate the existing code should be executed.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I do not understand what you meant to tell me.
I am supposed to check each and every object in the messageArr List<object> for the certain condition
and if it is true, I have to check the relevant Item in the CheckedListBox.
therefor the code must be executed any way for the best of my knowledge.
Is there something I am missing here?
do you see a situation where nothing needs to be done?
please enlighten me and tell me of which situation you speak.
how am I supposed to check the Item without calling Invoke?
|
|
|
|
|
Hi,
1.
your code seems OK.
I trust you have it working?
2.
what I meant to tell you was maybe your code runs even at times that there are
no messages, or all tests (valveAngDeg > 0) will fail, so nothing needs to be changed
in the GUI. If so, there was no need to let the GUI thread execute the function,
so if that is relevant you could do something like this (in pseudo-code):
void checkProblematicValvesNew() {
bool GuiChangeNeeded=false;
foreach(thing to be checked) {
if (GUI indeed needs a change) GuiChangeNeeded=true;
}
if (GuiChangeNeeded) {
checkProblematicValves();
}
}
but probably it is not really worth the effort...
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi guys,
Anybody knows how to work with the currently opened IM chat sessions (both msn and yahoo)? I need to develop a windows application, most probably in C# or VC, in which the messages coming in and out from the IM sessions need to be grabbed and recorded. This is required to be done in the backend. Please help me if anybody has worked on such or similar thing before.
Reference to any article or site which helps in this connection will also be appreciated.
Thankyou,
bABURmAN
|
|
|
|
|