Click here to Skip to main content
15,905,867 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hi all,

i am working webservices.

when i call the webservice it can take more than 5minutes to read the data from webservices. that time little bit irritating. So i want to showing the .gif image that time iam did that but it's not working.

let me know how can i do this.

in my code (windows forms)
1) iam taking grid
2) another form have progressbar control
3) when i call the webservice anotherform is showing
4) when i complete the webservice calling another form is closing

this is not working for me


in my code

when ever i debug the binddata calling otherwise not calling i don't know what's going on

so let me know where i wrong is there another way to do this

public partial class Form12 : Form
  {
      Test_Service Testsrvc = new Test_Service();
      Test[] test;

      private Thread th;
      //progressbar form
      private Form5 objFrm5 = new Form5();

      public Form12()
      {
          InitializeComponent();
          Load += new EventHandler(Form12_Load);
      }

      private void ShowDialog()
      {

          if (this.InvokeRequired)
          {
              objFrm5.ShowDialog();
          }
          else
          {
              //Start the thread that will execute this method
              th = new System.Threading.Thread(Binddata);
              th.IsBackground = true;
              th.Start();
          }

      }

      void Form12_Load(object sender, EventArgs e)
      {
          ShowDialog();
          if (th != null)
          {
              th.Abort();
              objFrm5.Close();
          }
      }

      private void Binddata()
      {

          Testsrvc.Credentials = new System.Net.NetworkCredential("UserName", "Pwd");
          test = Testsrvc.ReadMultiple(null, null, 0);
          dataGridView1.DataSource = Test;
          pictureBox1.Visible = false;
          progressBar1.Visible = false;
      }


  }
Posted
Updated 11-Aug-16 4:14am
v4

finally i did after knowing the delegate concepts.

 delegate void ProcessDelegate();

void Form12_Load(object sender, EventArgs e)
        {
            ProcessDelegate del = new ProcessDelegate(Binddata);
            del.BeginInvoke(new AsyncCallback(EndProcess), del);
            //it can handle the cross threading 
            Control.CheckForIllegalCrossThreadCalls = false;
        }

void EndProcess(IAsyncResult result)
        {
            if (result.IsCompleted) //if the async operation's result is true (done) then;
            {
                ProcessDelegate del = result.AsyncState as ProcessDelegate;
                del.EndInvoke(result);
            }
        }


now it's working fine.
 
Share this answer
 
hi
In windows form the animated gif wont work. It will only work only in browsers. If you want to create an animation, make it using wpf and you can add it your winform.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900