how does thread priority apply across the network

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bob

    #1

    how does thread priority apply across the network

    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


Working...