标签: freeze

主应用程序忙时如何避免线程冻结

我有一点问题.我想显示一个进度表单,它只是在主应用程序执行大量操作时显示动画.

我在一个线程中完成了这个,当用户没有执行任何操作时,它工作正常.但它只是在我的主应用程序繁忙时停止.

我无法将Application.ProcessMessages放在不同的代码行之间,因为我使用的是处理时间很长的第三方组件.

我的想法是创建一个新进程,并在此过程中创建一个执行动画的线程.现在,当主应用程序执行大量操作时,这不会停止执行线程.

但是正如我所看到的,如果你执行一个新程序,你只能创建一个新进程.

有没有人有一个解决方案,即使主应用程序繁忙时如何让线程继续执行?

/布赖恩

delphi multithreading freeze

1
推荐指数
2
解决办法
4684
查看次数

Android WebView中只有一个javascript警报,然后停止响应

我在WebChromeClient中为嵌入式WebView设置了一个javascript alert()处理程序:

@Override
public boolean onJsAlert(WebView view, String url, String message, final android.webkit.JsResult result)  
{
  Log.d("alert", message);
  Toast.makeText(activity.getApplicationContext(), message, 3000).show();
  return true;
};
Run Code Online (Sandbox Code Playgroud)

不幸的是,这只显示一次弹出式Toast,然后WebView停止响应任何事件.我甚至无法使用我的菜单命令加载另一个页面.我没有在LogCat中看到错误,这可能是什么问题?

android freeze webview toast

1
推荐指数
1
解决办法
1968
查看次数

我的网站处于冻结状态-可能是JavaScript,但我无法确定原因

我知道这是一个漫长的过程,所以我没有指望一个答案,但是我一生都无法弄清楚为什么这个网页设计会持续冻结我的浏览器。

http://fuzionve.com/test

我在Chrome开发人员工具中运行了审核工具,但似乎没有什么实质性的内容。当我在浏览器中加载它时,它会冻结,然后立即完全加载。

有什么建议么?

非常感谢你的帮助。

javascript jquery freeze

1
推荐指数
1
解决办法
1132
查看次数

文件阅读器冻结我的程序

运行以下方法时,我无法确定程序冻结的原因:

String fileName = "Drops.de";
        StreamReader streamReader = new StreamReader(fileName);
        String npcName;
        string npcID;
        string itemID;
        string itemAmount;
        string itemRarity;
        string itemName;

        while(!streamReader.EndOfStream){
            string line = streamReader.ReadLine();
            //start of block
            if(line.StartsWith("[")){
                npcName = line.TrimStart('[');
                npcName = npcName.TrimEnd(']');
                while(npcName == button1.Text){    
                while(!line.StartsWith("[/")){
                    line = streamReader.ReadLine();
                    String[] s = line.Split(' ');
                    npcID = (s[0]);
                    itemName = (s[1]);
                    itemID = (s[2]);
                    itemAmount = (s[3]);
                    itemRarity = (s[4]);
                    dataGridView1.Rows.Add(itemName, itemID, itemAmount, itemRarity);
                    /*
                    DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[0].Clone();
                    row.Cells[0].Value = itemName;
                    row.Cells[1].Value = itemID;
                    row.Cells[2].Value …
Run Code Online (Sandbox Code Playgroud)

c# methods datagridview file freeze

1
推荐指数
1
解决办法
135
查看次数

如何让一个线程不冻结整个JFrame.JAVA

嘿,我只需要一个问题解答...我如何使以下代码不冻结我的整个JFrame?

                try {
                Thread.sleep(Integer.parseInt(delayField.getText()) * 1000);
                System.out.println("Hello!");
            } catch(InterruptedException ex) {
                Thread.currentThread().interrupt();
            }
Run Code Online (Sandbox Code Playgroud)

java swing freeze jframe

1
推荐指数
1
解决办法
5271
查看次数

为什么java程序冻结在113882上?

我编写了一个java程序,使用collat​​z序列查找数字链的长度.collat​​z序列为:如果数字是偶数,则将其除以2,如果是奇数,则乘以3并加1.当数字达到1时序列结束.Clatz序列的附加信息.我的程序发现数字的链长从1到1百万,但它停在113382.没有显示错误信息,程序只是停止打印数字.

*编辑:我测试了它,结果是当程序在113383时,链收敛到负值.有谁能解释一下?

我已经包含了完整的代码,因为它很短.

public static void main(String[] args) {
    int max =0, maxChain=0;
    for(int i = 2; i <1000000; i++ )
    {
        int c =i;
        int counter = 0;
        while(c != 1)
        {
            if(c%2 ==0) c/=2;
            else c= 3*c+1;
            counter++;
        }
        if(counter > maxChain)
        {
            maxChain =counter;
            max = i;
        }
        System.out.println(i);
    }
    System.out.println(max +" has a chain length of " +maxChain);

}
Run Code Online (Sandbox Code Playgroud)

java freeze collatz

1
推荐指数
1
解决办法
344
查看次数

Android AsyncTask冻结了UI

我正试图从服务器获取数据.尽管事实上我在doinbackground方法中完成所有连接和提取数据,但UI仍会冻结.如果有人会帮助我,我将非常感激,因为我检查了有关该主题的所有问题并且没有找到解决方案.

public class GetMessagesActivity extends AsyncTask<String, Void, String> {
    private Context context;

    private ProgressDialog progressDialog;

    public GetMessagesActivity(Context context) {

        this.context = context;
        this.progressDialog = new ProgressDialog(context);
        this.progressDialog.setCancelable(false);
        this.progressDialog.setMessage("Updating...");
        this.progressDialog.show();

    }

    protected void onPreExecute() {
    }

    @Override
    protected String doInBackground(String... arg0) {
        try {
            String pid = "1";
            String link = "somelink";
            String data = URLEncoder.encode("pid", "UTF-8") + "="
            + URLEncoder.encode(pid, "UTF-8");
            // data += "&" + URLEncoder.encode("password", "UTF-8")
            // + "=" + URLEncoder.encode(password, "UTF-8");
            URL url = new URL(link);
            URLConnection …
Run Code Online (Sandbox Code Playgroud)

user-interface android freeze android-asynctask

1
推荐指数
1
解决办法
2873
查看次数

为什么在使用带有swift的while循环时iPhone似乎会冻结?

我试图通过使用while循环每2秒拍一张照片.但是当我尝试这个时,屏幕会冻结.
这是拍摄照片的功能:

func didPressTakePhoto(){

    if let videoConnection = stillImageOutput?.connectionWithMediaType(AVMediaTypeVideo){
        videoConnection.videoOrientation = AVCaptureVideoOrientation.Portrait
        stillImageOutput?.captureStillImageAsynchronouslyFromConnection(videoConnection, completionHandler: {
            (sampleBuffer, error) in

            if sampleBuffer != nil {


                let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(sampleBuffer)
                let dataProvider  = CGDataProviderCreateWithCFData(imageData)
                let cgImageRef = CGImageCreateWithJPEGDataProvider(dataProvider, nil, true, .RenderingIntentDefault)

                let image = UIImage(CGImage: cgImageRef!, scale: 1.0, orientation: UIImageOrientation.Right)

                UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)

                //Adds every image taken to an array each time the while loop loops which will then be used to create a timelapse.
                self.images.append(image)


            }


        })
    }


}
Run Code Online (Sandbox Code Playgroud)

为了拍照,我有一个按钮,当一个名为count的变量等于0时,将在while循环中使用该函数,但是当按下结束按钮时,该变量等于1,因此while循环结束.
这就是startPictureButton动作的样子: …

freeze timelapse while-loop swift

1
推荐指数
1
解决办法
581
查看次数

计时器打勾时Windows窗体冻结

我有一个问题,我的GUI在计时器滴答时冻结.

我的程序应该做什么:每30秒读取一次我的serialPort,将文本文件中的serialPort数据保存并在我的窗体上显示数据.一切正常,但每次计时器都会冻结我的GUI冻结4-5秒.

这里我的代码:( Visual C#)

-startButton(){...}
-RefreshComports(){...}
-stopButton(){...}



    private void timer1_Tick(object sender, EventArgs e)
    {
      myFile = new StreamWriter(path, true);
      serialPort1.NewLine = "\r";

      if (serialPort1.IsOpen == false)
      {
        serialPort1.Open();
      }
          data = serialPort1.ReadLine(); 

           myFile.WriteLine(data);

           if (data.Contains(':'))
           {
              String tmp[] = data.Split(':');
              textBox1.Text = tmp[1];
              textBox2.Text = tmo[2];
            }
            serialPort1.Close();
            myFile.Flush();
            myFile.Close();
}
Run Code Online (Sandbox Code Playgroud)

我尝试用backgroundworke而不是计时器来做这个,但后来我无法更新我的文本框.有人可以帮帮我吗?

c# timer freeze backgroundworker winforms

1
推荐指数
1
解决办法
3938
查看次数

jQuery页面冻结,同时用大量数据更新DOM

我有一个jQuery post方法,看起来像这样:

$.post("/SearchCompetitor/Index", { username: _username }, StartLoading())
                           .done(function (data) {
                               if (data !== "UsernameError") {
                                   StopLoading();
                                   var brands = $('<table />').append(data).find('#tableProducts').html();
                                   $('#tableProducts').html(brands);
                                   $("#tableProducts").simplePagination({

                                       // the number of rows to show per page
                                       perPage: 10,

                                       // CSS classes to custom the pagination
                                       containerClass: '',
                                       previousButtonClass: '',
                                       nextButtonClass: '',

                                       // text for next and prev buttons
                                       previousButtonText: 'Previous',
                                       nextButtonText: 'Next',

                                       // initial page
                                       currentPage: 1

                                   });
                                   var header = $('<div />').append(data).find('.bs-glyphicons').html();
                                   $('.bs-glyphicons').html(header);
                                   $('#tableProducts thead, #header').fadeIn("slow");
                                   $('#emptyText').hide();

                               }
                               else {
                                   StopLoading();
                                   ShowMessage("No …
Run Code Online (Sandbox Code Playgroud)

javascript c# jquery asynchronous freeze

1
推荐指数
1
解决办法
3058
查看次数