Click here to Skip to main content
15,891,316 members
Home / Discussions / C#
   

C#

 
GeneralRe: Getting the bin directory location for a service??!! Pin
justintimberlake2-May-07 19:05
justintimberlake2-May-07 19:05 
AnswerThe only thing that works with a service in the 2.0 framework Pin
LongRange.Shooter3-May-07 1:43
LongRange.Shooter3-May-07 1:43 
AnswerRe: Getting the bin directory location for a service??!! Pin
PIEBALDconsult3-May-07 15:31
mvePIEBALDconsult3-May-07 15:31 
GeneralRe: Getting the bin directory location for a service??!! Pin
LongRange.Shooter4-May-07 3:01
LongRange.Shooter4-May-07 3:01 
GeneralRe: Getting the bin directory location for a service??!! Pin
PIEBALDconsult4-May-07 16:47
mvePIEBALDconsult4-May-07 16:47 
GeneralRe: Getting the bin directory location for a service??!! Pin
PIEBALDconsult6-May-07 14:14
mvePIEBALDconsult6-May-07 14:14 
QuestionThread creation using reflection for the target? Pin
LongRange.Shooter1-May-07 9:55
LongRange.Shooter1-May-07 9:55 
AnswerRe: Thread creation using reflection for the target? Pin
Ian Shlasko1-May-07 10:21
Ian Shlasko1-May-07 10:21 
Well, a ThreadStart may be a zero-parameter delegate, but that method can contain anything...

<br />
_obj = Get_My_Object_Through_Reflection_Somehow<br />
<br />
Thread newThread = new Thread(new ThreadStart(RunObjMethod));<br />
newThread.Start();<br />
<br />
...<br />
<br />
private void RunObjMethod()<br />
{<br />
  _obj.Method();<br />
}<br />


There are of course ways to clean this up... You could pass the object and a string with the method name to a private class, and have the class do something like the above code in its constructor, just to keep everything encapsulated. Make it nice and general, and hook up a static method to wrap the constructor, and you can make it look like:

<br />
StartInThread.Launch(myObj, "MethodName");<br />
<br />
...<br />
<br />
private class StartInThread<br />
{<br />
  object _obj;<br />
  string _methName;<br />
<br />
  public static void Launch(object obj, string methName)<br />
  {<br />
    new StartInThread(obj, methName);<br />
  }<br />
  private StartInThread(object obj, string methName)<br />
  {<br />
    _obj = obj; _methName = methName;<br />
    Thread thrd = new Thread(new ThreadStart(Run));<br />
    thrd.Name = methName;<br />
    thrd.IsBackground = true;<br />
    thrd.Start();<br />
  }<br />
<br />
  private void Run()<br />
  {<br />
    ...get a MethodInfo for _methName in _obj, and call it directly...<br />
  }<br />
}<br />


(Pardon any syntax errors, since I just typed that up in this box)
GeneralRe: Thread creation using reflection for the target? Pin
LongRange.Shooter1-May-07 10:58
LongRange.Shooter1-May-07 10:58 
AnswerRe: Thread creation using reflection for the target? Pin
PIEBALDconsult1-May-07 18:26
mvePIEBALDconsult1-May-07 18:26 
QuestionC# Remote Window Hooks Pin
Bourtree1-May-07 9:40
Bourtree1-May-07 9:40 
AnswerRe: C# Remote Window Hooks Pin
LongRange.Shooter1-May-07 11:58
LongRange.Shooter1-May-07 11:58 
GeneralRe: C# Remote Window Hooks Pin
Bourtree3-May-07 6:51
Bourtree3-May-07 6:51 
GeneralRe: C# Remote Window Hooks Pin
LongRange.Shooter3-May-07 14:56
LongRange.Shooter3-May-07 14:56 
Questionarray of reference type in heap Pin
swjam1-May-07 8:59
swjam1-May-07 8:59 
AnswerRe: array of reference type in heap Pin
Ian Shlasko1-May-07 9:13
Ian Shlasko1-May-07 9:13 
AnswerRe: array of reference type in heap Pin
kubben1-May-07 9:14
kubben1-May-07 9:14 
GeneralRe: array of reference type in heap Pin
Ian Shlasko1-May-07 9:19
Ian Shlasko1-May-07 9:19 
GeneralRe: array of reference type in heap Pin
kubben1-May-07 9:22
kubben1-May-07 9:22 
AnswerRe: array of reference type in heap Pin
LongRange.Shooter1-May-07 9:50
LongRange.Shooter1-May-07 9:50 
AnswerRe: array of reference type in heap Pin
Guffa1-May-07 9:52
Guffa1-May-07 9:52 
QuestionProblme passing Double Quotes (") to query Pin
Muhammad Nauman Yousuf1-May-07 6:54
Muhammad Nauman Yousuf1-May-07 6:54 
AnswerRe: Problme passing Double Quotes (") to query Pin
kubben1-May-07 7:15
kubben1-May-07 7:15 
GeneralRe: Problme passing Double Quotes (") to query Pin
Muhammad Nauman Yousuf1-May-07 7:53
Muhammad Nauman Yousuf1-May-07 7:53 
GeneralRe: Problme passing Double Quotes (") to query Pin
kubben1-May-07 7:59
kubben1-May-07 7:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.