title: ProgressDialog And Thread
body: <p>I use <code>ProgressDialog</code> with Thread or <code>AsyncTask</code>.</p>
  
  <p>Both of <code>AsyncTask</code> And Thread Work. But In finish the work <code>ProgressDialog</code> Dismiss And get force close .</p>
  
  <p>In <code>onCreate()</code> i call this</p>
  
  <pre><code>new myAsyncTask().execute();
  </code></pre>
  
  <p>AsyncTask</p>
  
  <pre><code>private class myAsyncTask extends AsyncTask&lt;Void, Void, String&gt;
  {
  
      ProgressDialog dialog;
      @Override
      protected void onPreExecute() {
          dialog = ProgressDialog.show(MainActivity.this, "", "Please Wait !",true,false);
      }
      @Override
      protected String doInBackground(Void... params) {
          startProgram();
          return "";  
      }
      @Override
      protected void onPostExecute(String result) {
          if (dialog.isShowing())
              dialog.dismiss();
      }
  }
  </code></pre>