実行中のリーダーを停止することはできますか?読み取り中にデータリーダーを中断できますか?
シナリオ:100000データ
CREATE TABLE stock (
uid bigint NOT NULL,
name text,
quantity integer,
x bytea,
y bytea
);
、コンソールアプリケーション(.NET 4.0、Npgsqlの2.0.11.0/2.0.11.92)を設定すると、私はテーブルを持っているデータを読み出すための
conn = new NpgsqlConnection("Server=localhost;Database=postgres;User id=postgres;password=postgres;Timeout=600;CommandTimeout=600;ConnectionLifeTime=600;");
using (new ConnectionOpen(conn))
using (var ta = conn.BeginTransaction(IsolationLevel.Snapshot))
{
IDbCommand command = conn.CreateCommand("SELECT * from stock;");
command.SetTransaction(ta);
IDataReader reader = command.ExecuteReader();
int n = 0;
while (!reader.IsClosed && reader.Read())
{
n++;
if (n > 5000)
{
if (reader != null)
{
((NpgsqlDataReader)reader).Close();
}
}
}
((NpgsqlDataReader)reader).Dispose();
reader = null;
}
I実際に停止することはできませんデータリーダーを観察している。それは、データリーダーが最初にすべての行を読み取り、その後正常に返すようです。
この例は、読み取りに時間がかかりすぎるため、ボタンを押してデータリーダーを停止する大きなアプリケーションの要約です。
:上記情報の
部品から取得されました。私のシナリオでは、データリーダーの動作を確認するためのログ出力は、コマンド "((NpgsqlDataReader)reader).Close()"の後、常に待ち時間を示します。この待ち時間は、すべての行を読み出すとほぼ同じです。 – Joerg
!true && falseはfalseと評価されます。 !true XOR falseは真と評価されます。 –
そうです、これを更新します。 – oleksii