|
First Of all thanks for correcting me.. I made this program without knowing the contain function i donno y i havent looked that out ..
in addition.. the invoke key i have used was taken out from the mdsn site and i didnt really knew what the hell to do with it.. thanks for clearing that out
the program now works perfectly thank you !!
BUT
i wanted the process to work faster.. by adding more threads to the search program (where each thread looks at some other directory)thats what i meant by synchronizing threads and working with multi threads.. how can i do that?? consider your code as my base program code
and i can ask another question..
Multi threads and threadpool..
whats the difference between them??
is threadpool just a number of multi threads function?
thank you so much!
|
|
|
|
|
Multi threading isn't a simple solution to all your performance problems. You're accessing a disk here, and looping through every file and directory. Disk access is slow compared to CPU speeds. if you spawn multiple threads, all that's going to happen is they'll each be fighting over the disk because the disk won't be able to keep up with all the requests from the CPU.
It's like copying files. Try copying 2 large files separately, but start them at the same time. See how long it takes. Now try copying them one at a time and wait for the first to finish before you start the second, it'll take roughly the same amount of time in total, because by doing them both at the same all that happens is the CPU has to wait for the disk to be ready.
There is no easy way to speed up a full disk search, you've just got to sit it out. I suppose what you can do is have 1 thread for getting all the data from the disk, and a second to process it all, so thread 1 can carry on reading the disk while thread 2 is processing the data. But other than that, multi threading is not going to help you unless you have multiple disks, then you can target 1 thread at each disk.
(The other way to do things is to index the disk, and hold the index in memory. You would have to have a service or something to monitor the disk for changes. I assume this is how things like google desktop search works.)
Simon
|
|
|
|
|
Ok Got it thanks!
Can you please though give me an example of how to work with a multi threads situation??
this is not necessarily have to do with my program, i just want to go to know that feature cause i really cant seem to understand how to synchronize between threads..
And threadpool<>multi threads <-- what's the difference??
|
|
|
|
|
shinboxe wrote: threadpool<>multi threads <-- what's the difference??
Think of the thread pool as a pot of ready made threads available for you to use. Threads are relatively costly to create and manage, so if you just want to do some quick and simple actions on separate threads, you can request some threads from the pool, use them, then give them back when your finished. The thread pool will give you threads to meet your needs but when you've finished and you hand them back to the pool, it might keep them around and reuse them for other applications who use the pool rather than destroying and creating new threads every time someone needs them.
The disadvantage is that you lose some control over exactly how many threads you create and various other details like thread priority and stuff. You just tell the pool what jobs you want done with ThreadPool.QueueUserWorkItem(), and the pool will manage the threads for you.
There are lots of different ways to work with Threads, and it's not a simple topic, so I would suggest you get a good .Net book. "CLR via C#" and "Pro C# 2008 & the .Net 3.5 platform" both have good chapters on async operations and thread synchronisation with .Net
Simon
|
|
|
|
|
|
Hi,
How to know that an internet connection is alive at some instant of time?
I know that there are methods like InternetGetConnectedState and InternetCheckConnection which tell that whether a internet connection is alive and whether a particualr url is reachable..
But I would know this when I run the application..
But How to write a simple application which dynamically knows that the internet connection has just been estabilished? Or a particular url is reachable now (just like hooking?)
|
|
|
|
|
To check something is reachable, you could attempt to ping it.
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
I already know half the solution to this problem, as I told you that there are methods in 'wininet.dll' to know that internet connection is available, but I want to create an application which identifies the connection dynamically..
What I mean is that when the user plugs in his modem or anything like this which connects his system to internet, I want this application to write a log somewhere or maybe pop up a screen..
how do I do this?
|
|
|
|
|
You could always write an application that runs at Startup, and attempts the connection every second or so.
|
|
|
|
|
Did you mean to say I write a windows Service for that?
Well that would be very heavy performance wise..
Can you suggest something else please?
|
|
|
|
|
ptr2void wrote: Did you mean to say I write a windows Service for that?
Nope, as one of your requirements was for some form of UI. Just write your application to use a tray icon and have it run as part of the Startup process (i.e. if it's in the Startup directory in your start menu, it automatically gets started when the user logs in).
|
|
|
|
|
If I remember, there's a way to check if the internet connection is active through WMI. The failing of this method I remember was that you don't know if there's an internet connection but that the LAN connection is active. It is assumed that if the LAN is active there is an internet connection.
"Every time Lotus Notes starts up, somewhere a puppy, a kitten, a lamb, and a baby seal are killed. Lotus Notes is a conspiracy by the forces of Satan to drive us over the brink into madness. The CRC-32 for each file in the installation includes the numbers 666." Gary Wheeler
"You're an idiot." John Simmons, THE Outlaw programmer
"I realised that all of my best anecdotes started with "So there we were, pissed". Pete O'Hanlon
|
|
|
|
|
Mustafa Ismail Mustafa wrote: It is assumed that if the LAN is active there is an internet connection.
Assumed by who? A LAN connection does not mean that LAN has access to the internet!
|
|
|
|
|
J4amieC wrote: A LAN connection does not mean that LAN has access to the internet!
I know that, what I meant is the solution's draw back was that it assumes that if there is an active LAN connection then there is Internet connectivity.
"Every time Lotus Notes starts up, somewhere a puppy, a kitten, a lamb, and a baby seal are killed. Lotus Notes is a conspiracy by the forces of Satan to drive us over the brink into madness. The CRC-32 for each file in the installation includes the numbers 666." Gary Wheeler
"You're an idiot." John Simmons, THE Outlaw programmer
"I realised that all of my best anecdotes started with "So there we were, pissed". Pete O'Hanlon
|
|
|
|
|
Hi all..
How can set richtextbox transparent..?
Thank you..
%#&kmpYrlHSGYG5@#($_+!@!(*JASnjshdk,cm_0ashjhdbn@#$!48mkhfbchsh))^%#W%&@YW7wsdfjw789';'][]\`~JKJQ4$!@#~)-HSKS^&*1)JK12@#@$~!1`DFGkqp][]\]?Zas;EWRG%!@~)(^&BVAG
|
|
|
|
|
|
hi
how to get list of all tables that exist in my sql server instance ?
i'm using this scrpit :
select * from sys.tables
but this command return only tables that exist in Current Database.
thanks
|
|
|
|
|
How about posting here? http://www.codeproject.com/script/Forums/View.aspx?fid=1725
"Every time Lotus Notes starts up, somewhere a puppy, a kitten, a lamb, and a baby seal are killed. Lotus Notes is a conspiracy by the forces of Satan to drive us over the brink into madness. The CRC-32 for each file in the installation includes the numbers 666." Gary Wheeler
"You're an idiot." John Simmons, THE Outlaw programmer
"I realised that all of my best anecdotes started with "So there we were, pissed". Pete O'Hanlon
|
|
|
|
|
check this
use databasename<br />
select * from information_schema.tables
or this
SELECT *<br />
FROM dbo.sysobjects
or for more information check this...[^]
I Love T-SQL
|
|
|
|
|
thanks for reply
this is statements is very useful for me :
select * from information_schema.columns
but this scrpit only get information from current database while i want for all databases in server.
|
|
|
|
|
Then iterate over each of the databases performing the same query.
|
|
|
|
|
yes, of course.
but how to iterate through each database ?
|
|
|
|
|
To identify all user defined tables on a particular instance, you would use select name from master.sys.databases where owner_sid != 0x01
|
|
|
|
|
select name from master.sys.databases where owner_sid != 0x01
this script only list 3 database name for me :
ReportServer
ReportServerTempDB
AdventureWorks
|
|
|
|
|
hdv212 wrote: this script only list 3 database name for me :
ReportServer
ReportServerTempDB
AdventureWorks
And? How am I supposed to know what databases you have? I did state that this was per database instance so, if you think you are missing some, you need to check to see that you are hitting the right instance. For instance, you may find that one instance is running as (local) and the other as (local)\SQLExpress.
|
|
|
|