473,382 Members | 1,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

how does thread priority apply across the network

bob
I have a somewhat complex question about how Threading
works across the network. Below is the full source code
of a program that will list any file modified on
myServer. When I run this code from myWorkstation and
search myServer using a network share (using a Thread set
to priority.Lowest) does myWorkstation inform myServer
that this is a low priority thread? Since myServer is a
production server, I don't want my file monitoring
program to preempt other services running on the server
in any way.

Obviously, when the code is executed on myWorkstation,
the local CPU is well aware that the Thread is Low
priority. But when the file search is running on the
remote machine (myServer) CPU cycles are being used on
both machines. If anyone has any documentation or code
that will explain that myServer (would)/(would not) be
informed that this is a low priority thread I would be
very interested.

Thanks.
/************************************************** *******

FileMonitor.cs
This class lists the files modified on the C:\ drive of a
server (\\\\myServer\\c$\\) that have
been modified in the last 24 hrs.
A lot of this code has been modified from (FileCopy.cs)
code written by Bill Gearhart found @
http://www.aspemporium.com/aspEmpori...p/howtos/howto.
asp?hid=20
Thanks Bill!
Note: Lookout for line wrapping. This should compile fine.

*************************************/

using System;
using System.IO;
using System.Threading;

class FileMonitor
{
static void Main()
{
Thread
thread = new Thread(new ThreadStart(MyMethod));

thread.Priority = ThreadPriority.Lowest;

thread.Start();

Console.WriteLine(thread.Priority);
}

private static void MyMethod()
{
string
srcdir = Path.Combine(Environment.GetFolderPath
(Environment.SpecialFolder.DesktopDirectory), "\\\\myServe
r\\c$\\");
DirectoryInfo dir;
FileInfo[] files;
DirectoryInfo[] dirs;
string tmppath;
dir = new DirectoryInfo(srcdir);
if (! dir.Exists)
{
throw new ArgumentException("source dir
doesn't exist -> " + srcdir);
}
//get all files in the current dir
files = dir.GetFiles();
//loop through each file
foreach(FileInfo file in files)
{
tmppath=Path.Combine(srcdir, file.Name);

if (file.LastWriteTime.AddDays(1) >= DateTime.Now)

{

Console.WriteLine(tmppath);

}
}
//cleanup
files = null;
dirs = dir.GetDirectories();
foreach(DirectoryInfo subdir in dirs)
{
tmppath = Path.Combine(srcdir,
subdir.Name);
//recursively call this function over and
over again with each new dir.

MyMethod(subdir.FullName);

}
//cleanup
dirs = null;
dir = null;
}// end method
/************************************************** *******
This overloaded method below is one way to handle the
fact that...Thread thread = new Thread(new ThreadStart
(MyMethod)) will not take parameters to the method call.
*******************************************/

private static void
MyMethod(string srcdir)
{
DirectoryInfo dir;
FileInfo[] files;
DirectoryInfo[] dirs;
string tmppath;
dir = new DirectoryInfo(srcdir);
if (! dir.Exists)
{
throw new ArgumentException("source dir
doesn't exist -> " + srcdir);
}
//get all files in the current dir
files = dir.GetFiles();
foreach(FileInfo file in files)
{
tmppath=Path.Combine(srcdir,file.Name);

if (file.LastWriteTime.AddDays(1) >= DateTime.Now)

{

Console.WriteLine(tmppath);

}
}
//cleanup
files = null;
dirs = dir.GetDirectories();
//loop through each sub directory in the
current dir
foreach(DirectoryInfo subdir in dirs)
{
tmppath = Path.Combine(srcdir,
subdir.Name);
//recursively call this function over and
over again with each new dir.

MyMethod(subdir.FullName);
}
dirs = null;
dir = null;
} //end method
} //end class
Nov 15 '05 #1
0 1154

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

38
by: Anthony Baxter | last post by:
On behalf of the Python development team and the Python community, I'm happy to announce the release of Python 2.3.1 (final). Python 2.3.1 is a pure bug fix release of Python 2.3, released in...
5
by: Andrew Bartle | last post by:
Hi there, I have a web application that will be deployed for multiple clients. I would like to have a set of styles that apply to the site that can be overwritten for each specific client as...
5
by: Ken | last post by:
Hello Everyone, I think that there is no way to add a network printer in .Net. I have tried ,as an alternative, using windows API AddPrinter. This was not successful. Does anybody have a...
2
by: M. Raab | last post by:
i have a class that contains a method (not static) that is called on an event by child threads of the class. i assume it is not threadsafe. is there an attribute that i can set on the method that...
8
by: Cider123 | last post by:
I ran into a situation where my Window Service had to process 100,000+ files, when I first noticed I needed to tweak various routines. Everything runs fine, but here's what I ran into: In the...
4
by: Matthew Groch | last post by:
Hi all, I've got a server that handles a relatively high number of concurrent transactions (on the magnitude of 1000's per second). Client applications establish socket connections with the...
21
by: Willie jan | last post by:
place this behind a button that fills a listbox. as you will see the time is now and then 0 or filled in???????????? by hitting the button. is there a way to determine the real elapsed time? ...
3
by: John Nagle | last post by:
There's no way to set thread priorities within Python, is there? We have some threads that go compute-bound, and would like to reduce their priority slightly so the other operations, like...
8
by: Joe Withawk | last post by:
I have an application in which there exist a thread that handles directx rendering. It runs on a dual core system with windows vista and xp. It is set to have highest priority and simply loops with...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.