G
Guest
In my function I have to retrieve some data two times. The first time it runs
without any problem but on second call I get an timeout error.
I´m very confused about this behavior because following code runs on two of
our machines and timeout error raises only on one machine.
At the following lines I´ve postet same sample code, which produces this
error:
TransactionOptions o = new TransactionOptions();
o.IsolationLevel = System.Transactions.IsolationLevel.Serializable;
for (int i = 0; i < 10000; i++)
{
listBox1.Items.Insert(0, i.ToString());
using (TransactionScope scope = new
TransactionScope(TransactionScopeOption.Required, o))
{
GetData();
listBox1.Items.Insert(0, "1111");
Application.DoEvents();
GetData();
listBox1.Items.Insert(0, "2222");
Application.DoEvents();
scope.Complete();
}
}
private void GetData()
{
TypedDataSet ds = new TypedDataSet();
TypedDataSetTableAdapters.tblActivityTableAdapter adapter = new
TypedDataSetTableAdapters.tblActivityTableAdapter();
adapter.Fill(ds.tblActivity);
listBox1.Items.Clear();
foreach (TypedDataSet.tblActivityRow row in ds.tblActivity)
{
listBox1.Items.Add(row.strName);
}
label1.Text = ds.tblActivity.Rows.Count.ToString();
}
for (int i = 0; i < 10000; i++)
{
listBox1.Items.Insert(0, i.ToString());
using (TransactionScope scope = new
TransactionScope(TransactionScopeOption.Required, o))
{
GetData();
listBox1.Items.Insert(0, "1111");
Application.DoEvents();
GetData();
listBox1.Items.Insert(0, "2222");
Application.DoEvents();
scope.Complete();
Thanks.
without any problem but on second call I get an timeout error.
I´m very confused about this behavior because following code runs on two of
our machines and timeout error raises only on one machine.
At the following lines I´ve postet same sample code, which produces this
error:
TransactionOptions o = new TransactionOptions();
o.IsolationLevel = System.Transactions.IsolationLevel.Serializable;
for (int i = 0; i < 10000; i++)
{
listBox1.Items.Insert(0, i.ToString());
using (TransactionScope scope = new
TransactionScope(TransactionScopeOption.Required, o))
{
GetData();
listBox1.Items.Insert(0, "1111");
Application.DoEvents();
GetData();
listBox1.Items.Insert(0, "2222");
Application.DoEvents();
scope.Complete();
}
}
private void GetData()
{
TypedDataSet ds = new TypedDataSet();
TypedDataSetTableAdapters.tblActivityTableAdapter adapter = new
TypedDataSetTableAdapters.tblActivityTableAdapter();
adapter.Fill(ds.tblActivity);
listBox1.Items.Clear();
foreach (TypedDataSet.tblActivityRow row in ds.tblActivity)
{
listBox1.Items.Add(row.strName);
}
label1.Text = ds.tblActivity.Rows.Count.ToString();
}
for (int i = 0; i < 10000; i++)
{
listBox1.Items.Insert(0, i.ToString());
using (TransactionScope scope = new
TransactionScope(TransactionScopeOption.Required, o))
{
GetData();
listBox1.Items.Insert(0, "1111");
Application.DoEvents();
GetData();
listBox1.Items.Insert(0, "2222");
Application.DoEvents();
scope.Complete();
Thanks.