This is a migrated thread and some comments may be shown as answers.

GridView and Application Freeze

0 Answers 106 Views
GridView
This is a migrated thread and some comments may be shown as answers.
yusuf
Top achievements
Rank 1
yusuf asked on 29 Jan 2009, 11:00 PM

We have a problem in our Windows Forms Application. (.net 3.5)
We have many gridviews in different forms but they have same datasource which is datatable. Datatable gets updated rapidly by socket messages in socket class. Then gridviews refresh automaticaly when datatable gets updated.

The problem is gridviews freeze and it also freezes application.

we tried many difference solutions but they didnt work.

Any suggestions?

Thank you...

This is the sample of our program...

-----------Program.cs--------------------------------------------

        [STAThread]

        static void Main()

        {

            Application.EnableVisualStyles();

            Application.SetCompatibleTextRenderingDefault(false);

            Application.Run(new Main());

        }

------------------Main.cs--------------------------------------------------------------------------------

public partial class Main : Form

    {

        public Main()

        {

            InitializeComponent();           

        }

        private void Main_Load(object sender, EventArgs e)

        {

            GridForm form1 = new GridForm ();

            form1.MdiParent = this;

            form1.Show();

        }

    }

----------------GridForm.cs-----------(DataGridView in this Form)-----------------------

public partial class GridForm : Form

    {

        public GridForm()

        {

            InitializeComponent();

        }

        DataView dv_datatable;

        private void GridForm _Load(object sender, EventArgs e)

        {

            dv_ datatable = new DataView(Global.DT);

            x_GridView.DataSource = dv_ datatable;

        }

     }

--------------Socketp.cs------------------------------------------------------------------------------------

public class Socketp

    {

      public Socketp ()

        {

            bwListener = new BackgroundWorker();

            bwListener.WorkerSupportsCancellation = true;

            bwListener.DoWork += new DoWorkEventHandler(bwListener_DoWork);

            bwListener.RunWorkerAsync();

        }

        void bwListener_DoWork(object sender, DoWorkEventArgs e)

        {

            SubscribeServer();

        }

public void SubscribeServer()

        {

            //Some Socket Codes

            IPEndPoint ipe = new IPEndPoint//…

            clientSocket = new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp);           

            clientSocket.Connect(ipe); networkStream = new NetworkStream(clientSocket);  

            …        

            //Some Socket Codes

 

            while (clientSocket.Connected)

            {

                ///SomeCodes

            byte[] buffer = new byte[clientSocket.ReceiveBufferSize];

                ///SomeCodes

 

          DataRow rowx = Global.DT.NewRow();

          rowx ["ISLEM"] = fields[3];

          Global.DT.Rows.Add(rowx);//DataGridView is updated auto...

            }

        }

       

    }

 

Note : Form's DoubleBuffered attribute is true.

No answers yet. Maybe you can help?

Tags
GridView
Asked by
yusuf
Top achievements
Rank 1
Share this question
or