Show / Hide Table of Contents

    Class ThreadClass

    Support class used to handle threads that is inheritable just like the Thread type in Java. This class also ensures that when an error is thrown on a background thread, it will be properly re-thrown on the calling thread, which is the same behavior as we see in Lucene.

    Inheritance
    System.Object
    ThreadClass
    ControlledRealTimeReopenThread<T>
    TimeLimitingCollector.TimerThread
    Implements
    IThreadRunnable
    Inherited Members
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    Namespace: Lucene.Net.Support.Threading
    Assembly: Lucene.Net.dll
    Syntax
    public class ThreadClass : IThreadRunnable

    Constructors

    | Improve this Doc View Source

    ThreadClass()

    Initializes a new instance of the ThreadClass class

    Declaration
    public ThreadClass()
    | Improve this Doc View Source

    ThreadClass(String)

    Initializes a new instance of the Thread class.

    Declaration
    public ThreadClass(string name)
    Parameters
    Type Name Description
    System.String name

    The name of the thread

    | Improve this Doc View Source

    ThreadClass(ThreadStart)

    Initializes a new instance of the Thread class.

    Declaration
    public ThreadClass(ThreadStart start)
    Parameters
    Type Name Description
    System.Threading.ThreadStart start

    A ThreadStart delegate that references the methods to be invoked when this thread begins executing

    | Improve this Doc View Source

    ThreadClass(ThreadStart, String)

    Initializes a new instance of the Thread class.

    Declaration
    public ThreadClass(ThreadStart start, string name)
    Parameters
    Type Name Description
    System.Threading.ThreadStart start

    A ThreadStart delegate that references the methods to be invoked when this thread begins executing

    System.String name

    The name of the thread

    Properties

    | Improve this Doc View Source

    Instance

    Gets the current thread instance

    Declaration
    public Thread Instance { get; set; }
    Property Value
    Type Description
    System.Threading.Thread
    | Improve this Doc View Source

    IsAlive

    Gets a value indicating the execution status of the current thread

    Declaration
    public bool IsAlive { get; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    IsBackground

    Gets or sets a value indicating whether or not a thread is a background thread.

    Declaration
    public bool IsBackground { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    IsDebug

    If true when Join(), Join(Int64) or Join(Int64, Int32) is called, any original exception and error message will be wrapped into a new System.Exception when thrown, so debugging tools will show the correct stack trace information.

    NOTE: This changes the original exception type to System.Exception, so this setting should not be used if control logic depends on the specific exception type being thrown. An alternative way to get the original System.Exception.ToString() message is to use exception.Data["OriginalMessage"].ToString().

    Declaration
    public bool IsDebug { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    Name

    Gets or sets the name of the thread

    Declaration
    public string Name { get; set; }
    Property Value
    Type Description
    System.String
    | Improve this Doc View Source

    State

    Declaration
    public ThreadState State { get; }
    Property Value
    Type Description
    System.Threading.ThreadState

    Methods

    | Improve this Doc View Source

    Current()

    Gets the currently running thread

    Declaration
    public static ThreadClass Current()
    Returns
    Type Description
    ThreadClass

    The currently running thread

    | Improve this Doc View Source

    CurrentThread()

    Declaration
    public static ThreadClass CurrentThread()
    Returns
    Type Description
    ThreadClass
    | Improve this Doc View Source

    Equals(Object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    System.Object obj
    Returns
    Type Description
    System.Boolean
    Overrides
    System.Object.Equals(System.Object)
    | Improve this Doc View Source

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    System.Int32
    Overrides
    System.Object.GetHashCode()
    | Improve this Doc View Source

    Interrupt()

    Interrupts a thread that is in the WaitSleepJoin thread state

    Declaration
    public virtual void Interrupt()
    | Improve this Doc View Source

    Join()

    Blocks the calling thread until a thread terminates

    Declaration
    public void Join()
    | Improve this Doc View Source

    Join(Int64)

    Blocks the calling thread until a thread terminates or the specified time elapses

    Declaration
    public void Join(long milliSeconds)
    Parameters
    Type Name Description
    System.Int64 milliSeconds

    Time of wait in milliseconds

    | Improve this Doc View Source

    Join(Int64, Int32)

    Blocks the calling thread until a thread terminates or the specified time elapses

    Declaration
    public void Join(long milliSeconds, int nanoSeconds)
    Parameters
    Type Name Description
    System.Int64 milliSeconds

    Time of wait in milliseconds

    System.Int32 nanoSeconds

    Time of wait in nanoseconds

    | Improve this Doc View Source

    Resume()

    Resumes a thread that has been suspended

    Declaration
    public void Resume()
    | Improve this Doc View Source

    Run()

    This method has no functionality unless the method is overridden

    Declaration
    public virtual void Run()
    | Improve this Doc View Source

    SafeRun(ThreadStart)

    Safely starts the method passed to start and stores any exception that is thrown. The first exception will stop execution of the method passed to start and it will be re-thrown on the calling thread after it calls Join(), Join(Int64), or Join(Int64, Int32).

    Declaration
    protected virtual void SafeRun(ThreadStart start)
    Parameters
    Type Name Description
    System.Threading.ThreadStart start

    A System.Threading.ThreadStart delegate that references the methods to be invoked when this thread begins executing

    | Improve this Doc View Source

    SetDaemon(Boolean)

    Declaration
    public void SetDaemon(bool isDaemon)
    Parameters
    Type Name Description
    System.Boolean isDaemon
    | Improve this Doc View Source

    Sleep(Int64)

    Declaration
    public static void Sleep(long ms)
    Parameters
    Type Name Description
    System.Int64 ms
    | Improve this Doc View Source

    Start()

    Causes the operating system to change the state of the current thread instance to ThreadState.Running

    Declaration
    public virtual void Start()
    | Improve this Doc View Source

    Suspend()

    Suspends the thread, if the thread is already suspended it has no effect

    Declaration
    public void Suspend()
    | Improve this Doc View Source

    ToString()

    Obtain a String that represents the current object

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String

    A String that represents the current object

    Overrides
    System.Object.ToString()

    Operators

    | Improve this Doc View Source

    Equality(ThreadClass, Object)

    Declaration
    public static bool operator ==(ThreadClass t1, object t2)
    Parameters
    Type Name Description
    ThreadClass t1
    System.Object t2
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    Inequality(ThreadClass, Object)

    Declaration
    public static bool operator !=(ThreadClass t1, object t2)
    Parameters
    Type Name Description
    ThreadClass t1
    System.Object t2
    Returns
    Type Description
    System.Boolean

    Implements

    IThreadRunnable

    Extension Methods

    Number.IsNumber(Object)
    • Improve this Doc
    • View Source
    Back to top Copyright © 2019 Licensed to the Apache Software Foundation (ASF)