Click here to Skip to main content
16,005,467 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Database connection Pin
EmZan29-Apr-09 0:06
EmZan29-Apr-09 0:06 
Questionsecurity problem in asp.net Pin
deepak baldia9-Apr-09 19:15
deepak baldia9-Apr-09 19:15 
AnswerRe: security problem in asp.net Pin
Colin Angus Mackay10-Apr-09 2:48
Colin Angus Mackay10-Apr-09 2:48 
Questionhello Pin
mohamedmrc9-Apr-09 10:02
mohamedmrc9-Apr-09 10:02 
AnswerRe: hello Pin
Eddy Vluggen9-Apr-09 10:47
professionalEddy Vluggen9-Apr-09 10:47 
AnswerRe: hello Pin
led mike9-Apr-09 10:56
led mike9-Apr-09 10:56 
GeneralRe: hello Pin
Pete O'Hanlon12-Apr-09 11:03
mvePete O'Hanlon12-Apr-09 11:03 
QuestionSafe thread termination in unmanaged code Pin
supercat99-Apr-09 8:06
supercat99-Apr-09 8:06 
If I have a quantity of unmanaged code (in C, designed for another system), and most of it could be safely terminated at any time but it makes callbacks into managed code which could not be so terminated, would it be safe to do something like:
/* In the unmanaged section */
volatile int statflag;
/* Zero when running C code that may be terminated.
   One when running code that must not be terminated.
   Two when termination has been requested */

  if (Exchange(&statflag, 1) == 0)
  {
    call_managed_code();
    if (Exchange(&statflag, 0) != 1))
      terminate();
  }
  else
    terminate();

' In the other thread...
  If Threading.Interlocked.Exchange(safeflag, 2) = 0 Then
    TheThread.Terminate

If the portion of the code which is in C never does anything that could not be safely stopped asynchronously while safeflag is one, would there be any danger in calling Terminate() upon such a thread? Obviously any resources that had been allocated by that thread would have to be freed elsewhere, but in this particular application I'm not expecting the unmanaged code to use only resources that are given to it by other code (which could then take care of any necessary de-allocation).

In the particular application, there is a risk that the C portion of the code could hang without any callbacks to the managed portion, so I'd like to be able to use something more "potent" than Thread.Interrupt; is Thread.Terminate safe if used only upon a thread which is known not to hold any locks or be manipulating any other dangerous constructs?
AnswerRe: Safe thread termination in unmanaged code Pin
led mike9-Apr-09 9:10
led mike9-Apr-09 9:10 
GeneralRe: Safe thread termination in unmanaged code Pin
supercat99-Apr-09 9:44
supercat99-Apr-09 9:44 
GeneralRe: Safe thread termination in unmanaged code Pin
led mike9-Apr-09 10:55
led mike9-Apr-09 10:55 
GeneralRe: Safe thread termination in unmanaged code Pin
supercat99-Apr-09 11:43
supercat99-Apr-09 11:43 
GeneralRe: Safe thread termination in unmanaged code Pin
Luc 64801110-Apr-09 2:57
Luc 64801110-Apr-09 2:57 
GeneralRe: Safe thread termination in unmanaged code Pin
led mike10-Apr-09 5:37
led mike10-Apr-09 5:37 
Questionam i a programmer or not [modified] Pin
rilm9-Apr-09 7:48
rilm9-Apr-09 7:48 
AnswerRe: am i a programmer or not Pin
Paulo Zemek9-Apr-09 8:19
Paulo Zemek9-Apr-09 8:19 
GeneralRe: am i a programmer or not Pin
led mike9-Apr-09 8:41
led mike9-Apr-09 8:41 
GeneralRe: am i a programmer or not Pin
dojohansen15-Apr-09 1:40
dojohansen15-Apr-09 1:40 
GeneralRe: am i a programmer or not Pin
led mike15-Apr-09 11:49
led mike15-Apr-09 11:49 
GeneralRe: am i a programmer or not Pin
dojohansen16-Apr-09 0:44
dojohansen16-Apr-09 0:44 
GeneralRe: am i a programmer or not Pin
led mike16-Apr-09 5:18
led mike16-Apr-09 5:18 
GeneralRe: am i a programmer or not Pin
dojohansen16-Apr-09 5:29
dojohansen16-Apr-09 5:29 
GeneralRe: am i a programmer or not Pin
led mike16-Apr-09 7:30
led mike16-Apr-09 7:30 
AnswerRe: am i a programmer or not Pin
led mike9-Apr-09 8:43
led mike9-Apr-09 8:43 
GeneralRe: am i a programmer or not Pin
rilm11-Apr-09 11:22
rilm11-Apr-09 11:22 

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.