473,809 Members | 2,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Threadin g;

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

thread.Priority = ThreadPriority. Lowest;

thread.Start();

Console.WriteLi ne(thread.Prior ity);
}

private static void MyMethod()
{
string
srcdir = Path.Combine(En vironment.GetFo lderPath
(Environment.Sp ecialFolder.Des ktopDirectory), "\\\\myServ e
r\\c$\\");
DirectoryInfo dir;
FileInfo[] files;
DirectoryInfo[] dirs;
string tmppath;
dir = new DirectoryInfo(s rcdir);
if (! dir.Exists)
{
throw new ArgumentExcepti on("source dir
doesn't exist -> " + srcdir);
}
//get all files in the current dir
files = dir.GetFiles();
//loop through each file
foreach(FileInf o file in files)
{
tmppath=Path.Co mbine(srcdir, file.Name);

if (file.LastWrite Time.AddDays(1) >= DateTime.Now)

{

Console.WriteLi ne(tmppath);

}
}
//cleanup
files = null;
dirs = dir.GetDirector ies();
foreach(Directo ryInfo subdir in dirs)
{
tmppath = Path.Combine(sr cdir,
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(s rcdir);
if (! dir.Exists)
{
throw new ArgumentExcepti on("source dir
doesn't exist -> " + srcdir);
}
//get all files in the current dir
files = dir.GetFiles();
foreach(FileInf o file in files)
{
tmppath=Path.Co mbine(srcdir,fi le.Name);

if (file.LastWrite Time.AddDays(1) >= DateTime.Now)

{

Console.WriteLi ne(tmppath);

}
}
//cleanup
files = null;
dirs = dir.GetDirector ies();
//loop through each sub directory in the
current dir
foreach(Directo ryInfo subdir in dirs)
{
tmppath = Path.Combine(sr cdir,
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 1174

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

Similar topics

38
2914
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 late July. A number of obscure crash-causing bugs have been fixed, various memory leaks have been squished, but no new features have been added to the language or to the library. For more information on Python 2.3.1, including download links for...
5
6411
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 required. My proposed approach is to have two stylesheets: one containing all the default styles, and the other containing those styles that I want overwritten for the specific instance. This requires control over which stylesheet takes priority....
5
19778
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 possible solution in .NET? Thank You in Advance for Your Help, Ken
2
1850
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 would cause the runtime to handle the method in a thread safe way? or do i need to put in my own locks? thanks m
8
2796
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 routine that loops through the file buffer: for (int i=0;i < _Buffer.length; i++) { // Code here
4
5437
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 server. Data is sent and received over these connections using the asynchronous model. The server is currently in beta testing. Sporadically over the course of the day, I'll observe the thread count on the process (via perfmon) start climbing....
21
4398
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? thanks, Willie Dim T As Double
3
35457
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 accessing the database and servicing queries, aren't slowed as much. John Nagle
8
2286
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 while(isRendering) { prepare for rendering; do render; present() }
0
10633
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10375
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9198
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7651
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.