Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d87bff8

Browse files
authored
Update async.cs (#402)
Updated license, comments, and code.
1 parent 6abc80b commit d87bff8

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

‎samples/async/async.cs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@
33
using System.Threading;
44
using System;
55

6-
// This code sample demonstrates using asynchronous ODP.NET (managed or core) and times its execution time.
7-
// This sample uses the Oracle HR sample schema.
6+
// This app uses asynchronous ODP.NET (managed or core) APIs to open a connection,
7+
// execute a SQL statement, and read the results. It times how long these operations take.
8+
// To run this app, add your database's HR schema User Id, Password, and Data Source values
9+
// with ODP.NET 23ai or higher connecting to an Oracle Database 19c or higher.
810

911
class ODPNET_Async
1012
{
1113
public static async Task Main()
1214
{
1315
// Add password and data source to connect to your Oracle database
14-
string conString = @"User Id=hr;Password=<PASSWORD>;Data Source=<NET SERVICE NAME>;";
16+
string conString = "User Id=hr;Password=<PASSWORD>;Data Source=<DATA SOURCE>;";
1517

1618
using (OracleConnection con = new OracleConnection(conString))
1719
{
18-
// Measure time OpenAsync takes before next operation can start execution
20+
//Time how long it takes to open a connection asynchronously
1921
DateTime start_time = DateTime.Now;
2022
Task task = con.OpenAsync();
2123
DateTime end_time_open = DateTime.Now;
@@ -25,46 +27,44 @@ public static async Task Main()
2527

2628
string cmdText = "SELECT * FROM EMPLOYEES FETCH FIRST 100 ROWS ONLY";
2729
using (OracleCommand cmd = new OracleCommand(cmdText, con))
28-
{
29-
// Retrieve open connection with "await"
30+
{
31+
// Retrieve open connection
3032
await task;
31-
32-
// Execute SELECT statement asynchronously
3333
using (OracleDataReader reader = await cmd.ExecuteReaderAsync())
3434
{
35-
// Retrieve results asynchronously
3635
await reader.ReadAsync();
3736
}
3837
}
39-
// Measure time all the async operations took
4038
DateTime end_time_all = DateTime.Now;
4139

42-
// Calculate connection open time and write result to console
40+
// Calculate connection open time
4341
TimeSpan ts_open = end_time_open - start_time;
4442
double ts_open1 = Math.Round(ts_open.TotalSeconds, 2);
4543
Console.WriteLine("Asynchronous connection open time: " + ts_open1 + " seconds");
4644

47-
// Calculate overall operation time and write to console
45+
// Calculate overall ODP.NET operation time
4846
TimeSpan ts_all = end_time_all - start_time;
4947
double ts_all1 = Math.Round(ts_all.TotalSeconds, 2);
50-
Console.WriteLine("Asynchronous ODP.NET operations time: " + ts_all1 + " seconds");
48+
Console.WriteLine("Asynchronous ODP.NET overall time: " + ts_all1 + " seconds");
5149
}
5250
}
5351
}
5452

55-
/* Copyright (c) 2023Oracle and/or its affiliates. All rights reserved. */
53+
/* Copyright (c) 2023, 2024 Oracle and/or its affiliates. All rights reserved. */
5654

5755
/******************************************************************************
58-
* Licensed under the Apache License, Version 2.0 (the "License");
59-
* you may not use this file except in compliance with the License.
60-
* You may obtain a copy of the License at
6156
*
62-
* http://www.apache.org/licenses/LICENSE-2.0
57+
* You may not use the identified files except in compliance with The MIT
58+
* License (the "License.")
59+
*
60+
* You may obtain a copy of the License at
61+
* https://github.com/oracle/Oracle.NET/blob/master/LICENSE.txt
62+
*
63+
* Unless required by applicable law or agreed to in writing, software
64+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
65+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
66+
*
67+
* See the License for the specific language governing permissions and
68+
* limitations under the License.
6369
*
64-
* Unless required by applicable law or agreed to in writing, software
65-
* distributed under the License is distributed on an "AS IS" BASIS,
66-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
67-
* See the License for the specific language governing permissions and
68-
* limitations under the License.
69-
*
7070
*****************************************************************************/

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /