Thread hanging

Asked

Viewed 347 times

0

My system has a method that puts each event fired into one thread, save, edit, search, everything goes to one thread.

  backgroundWorker.DoWork += acaoProcessamento;
  backgroundWorker.RunWorkerCompleted += (s, a) =>
  {
        this.ocooreuErro = a.Error != null;
        if ((a.Cancelled == true))
              this.lblDescricao.Text = "Cancelado!";            
        this.Refresh();
        this.Close();
  };

  backgroundWorker.RunWorkerCompleted += acaoConcluir;
  backgroundWorker.ProgressChanged += (s, a) =>
  {
        prbProgresso.Value = Math.Min(100, a.ProgressPercentage);
        prbProgresso.Style = prbProgresso.Value == 100
            ? ProgressBarStyle.Marquee
            : ProgressBarStyle.Continuous;
        prbProgresso.Visible = prbProgresso.Value > 0;
        if (a.UserState != null)
              lblDescricao.Text = a.UserState.ToString();
  };
  backgroundWorker.ReportProgress(0);
  backgroundWorker.RunWorkerAsync();
  this.ShowDialog();

But a specific routine when it comes to this this.ShowDialog();, does not fire a shot Exception, No mistake, nothing, just stop the application on that line and don’t walk anymore. At first I will not post more codes because I do not know which part of the code could help.

  • 1

    It’s Winforms or WPF?

  • 2

    Watch out for that misspelled "rustle".

  • 1

    Have you checked your thread is not in infinite loop?

  • 1

    Have you considered using http://msdn.microsoft.com/en-us/library/system.threading.tasks.task(v=vs.110). aspx instead of thread gross?

  • Opa Bigown, is winform, is a delicate point that code ai pq is found in a form used as inheritance in all other application, and as I caught the tram walking still do not want to make very impact changes(but if there is no other way...) I will check the possibility of loop.

  • Check that the Windows Event Viewer has not registered a entry detailing the exception that occurred. The ideal would be to "envelop" your codes (each delegate, inclusive) with Try/catch to avoid surprise closures of your application.

Show 1 more comment

1 answer

1

Without concrete evidence of the state in which it finds itself it is very difficult to locate the problem. So my recommendation is to activate an operation trace.
Log relevant information from the implementing context:

var linha = new StackTrace(new StackFrame(true)).GetFrame(0).GetFileLineNumber();
var nome = Assembly.GetExecutingAssembly().GetName().Name.ToString();
Debug.WriteLine(nome + "-" + linha + "-Variavel tal : " + sProdName );

You can use the Debugview to capture the messages.

  • After some treatment codes I managed to at least blow up an Exception, where it said that the backgroundWorker could not perform more than one function, but the strange thing is that in the standard form used as inheritance in all other forms of the solution, this backgroundWorker calls 2 methods of an interface used in all Form inherited from Formpadrao, "Prevalidarsalvar()" and "Save()", and as amazing as it seems to take the part of the preVariationSalvar that varies from form to form, all Forms are equal, but finally thanks for the attention, another analyst will check to find a solution, then I put here

Browser other questions tagged

You are not signed in. Login or sign up in order to post.