Skip to content

Commit 1a67a5b

Browse files
committed
Events reworked/fixed
1 parent 2123758 commit 1a67a5b

26 files changed

+890
-403
lines changed

Provider/nuget/FirebirdSql.Data.FirebirdClient/FirebirdSql.Data.FirebirdClient.nuspec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1414
<tags>firebird firebirsql firebirdclient adonet database</tags>
1515
<dependencies>
16+
<group targetFramework="net40-client">
17+
<dependency id="Microsoft.Bcl.Async" version="1.0.168" />
18+
</group>
1619
<group targetFramework="netstandard1.6">
1720
<dependency id="Microsoft.Extensions.PlatformAbstractions" version="1.0.0" />
1821
<dependency id="System.Collections.NonGeneric" version="4.0.1" />

Provider/src/EntityFramework.Firebird/EntityFramework.Firebird_NET40.csproj

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<Prefer32Bit>false</Prefer32Bit>
1515
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
1616
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
17+
<AppConfig>app.EntityFramework.Firebird_NET40.config</AppConfig>
1718
</PropertyGroup>
1819
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1920
<OutputPath>bin\Debug\NET40\</OutputPath>
@@ -41,10 +42,29 @@
4142
</ItemGroup>
4243
<ItemGroup>
4344
<Reference Include="Microsoft.CSharp" />
45+
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
46+
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
47+
</Reference>
48+
<Reference Include="Microsoft.Threading.Tasks.Extensions, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
49+
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
50+
</Reference>
51+
<Reference Include="Microsoft.Threading.Tasks.Extensions.Desktop, Version=1.0.168.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
52+
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
53+
</Reference>
4454
<Reference Include="System" />
4555
<Reference Include="System.Configuration" />
4656
<Reference Include="System.Core" />
4757
<Reference Include="System.Data" />
58+
<Reference Include="System.IO, Version=2.6.8.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
59+
<HintPath>..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.IO.dll</HintPath>
60+
</Reference>
61+
<Reference Include="System.Net" />
62+
<Reference Include="System.Runtime, Version=2.6.8.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
63+
<HintPath>..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Runtime.dll</HintPath>
64+
</Reference>
65+
<Reference Include="System.Threading.Tasks, Version=2.6.8.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
66+
<HintPath>..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Threading.Tasks.dll</HintPath>
67+
</Reference>
4868
<Reference Include="System.XML" />
4969
</ItemGroup>
5070
<ItemGroup>
@@ -125,6 +145,8 @@
125145
<EmbeddedResource Include="..\FirebirdSql.Data.FirebirdClient\Entity\StoreSchemaMappingVersion3.msl">
126146
<Link>Resources\StoreSchemaMappingVersion3.msl</Link>
127147
</EmbeddedResource>
148+
<None Include="app.EntityFramework.Firebird_NET40.config" />
149+
<None Include="packages.config" />
128150
<None Include="Properties\EntityFramework.Firebird.snk" />
129151
</ItemGroup>
130152
<ItemGroup>
@@ -139,4 +161,9 @@
139161
</ProjectReference>
140162
</ItemGroup>
141163
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
164+
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
165+
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
166+
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
167+
<Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
168+
</Target>
142169
</Project>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<runtime>
4+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
5+
<dependentAssembly>
6+
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
7+
<bindingRedirect oldVersion="0.0.0.0-2.6.8.0" newVersion="2.6.8.0" />
8+
</dependentAssembly>
9+
<dependentAssembly>
10+
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
11+
<bindingRedirect oldVersion="0.0.0.0-2.6.8.0" newVersion="2.6.8.0" />
12+
</dependentAssembly>
13+
</assemblyBinding>
14+
</runtime>
15+
</configuration>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Microsoft.Bcl" version="1.1.8" targetFramework="net40-client" />
4+
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net40-client" />
5+
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40-client" />
6+
</packages>

Provider/src/FirebirdSql.Data.FirebirdClient/Client/Managed/GdsConnection.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ internal class GdsConnection
5656

5757
#region Properties
5858

59-
public bool IsConnected
60-
{
61-
get { return _socket?.Connected ?? false; }
62-
}
59+
#warning Events
60+
//public bool IsConnected
61+
//{
62+
// get { return _socket?.Connected ?? false; }
63+
//}
6364

6465
public int ProtocolVersion
6566
{

Provider/src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version10/GdsDatabase.cs

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
using System.Net;
2727
using System.Text;
2828
using System.Threading;
29-
29+
using System.Threading.Tasks;
3030
using FirebirdSql.Data.Common;
3131

3232
namespace FirebirdSql.Data.Client.Managed.Version10
@@ -61,7 +61,6 @@ public WarningMessageCallback WarningMessage
6161
protected string _serverVersion;
6262
private short _packetSize;
6363
private short _dialect;
64-
private int _eventsId;
6564
private bool _disposed;
6665
private XdrStream _xdrStream;
6766

@@ -154,7 +153,6 @@ public void Dispose()
154153
_eventManager = null;
155154
_serverVersion = null;
156155
_dialect = 0;
157-
_eventsId = 0;
158156
_handle = 0;
159157
_packetSize = 0;
160158
_warningMessage = null;
@@ -224,6 +222,8 @@ public virtual void Detach()
224222

225223
try
226224
{
225+
CloseEventManager();
226+
227227
if (_handle != 0)
228228
{
229229
XdrStream.Write(IscCodes.op_detach);
@@ -232,8 +232,6 @@ public virtual void Detach()
232232
XdrStream.Write(IscCodes.op_disconnect);
233233
XdrStream.Flush();
234234

235-
CloseEventManager();
236-
237235
CloseConnection();
238236

239237
#warning Here
@@ -258,7 +256,6 @@ public virtual void Detach()
258256
{
259257
throw IscException.ForErrorCode(IscCodes.isc_network_error, ex2);
260258
}
261-
262259
throw IscException.ForErrorCode(IscCodes.isc_network_error, ex);
263260
}
264261
}
@@ -411,10 +408,12 @@ public virtual void ConnectionRequest(out int auxHandle, out string ipAddress, o
411408
#endregion
412409

413410
#region Connection Methods
411+
414412
public void CloseConnection()
415413
{
416414
_connection.Disconnect();
417415
}
416+
418417
#endregion
419418

420419
#region Remote Events Methods
@@ -423,42 +422,39 @@ public void CloseEventManager()
423422
{
424423
if (_eventManager != null)
425424
{
426-
_eventManager.Close();
425+
_eventManager.Dispose();
427426
_eventManager = null;
428427
}
429428
}
430429

431-
public RemoteEvent CreateEvent()
432-
{
433-
return new RemoteEvent(this);
434-
}
435-
436-
public void QueueEvents(RemoteEvent events)
430+
public void QueueEvents(RemoteEvent remoteEvent)
437431
{
438-
if (_eventManager == null)
439-
{
440-
ConnectionRequest(out var auxHandle, out var ipAddress, out var portNumber);
441-
_eventManager = new GdsEventManager(auxHandle, ipAddress, portNumber);
442-
}
443432
try
444433
{
445-
events.LocalId = Interlocked.Increment(ref _eventsId);
446-
_eventManager.QueueEvents(events);
434+
if (_eventManager == null)
435+
{
436+
ConnectionRequest(out var auxHandle, out var ipAddress, out var portNumber);
437+
_eventManager = new GdsEventManager(auxHandle, ipAddress, portNumber);
438+
var dummy = _eventManager.WaitForEventsAsync(remoteEvent);
439+
}
447440

448-
EventParameterBuffer epb = events.ToEpb();
441+
remoteEvent.LocalId++;
442+
443+
EventParameterBuffer epb = remoteEvent.BuildEpb();
444+
byte[] epbData = epb.ToArray();
449445

450446
XdrStream.Write(IscCodes.op_que_events);
451447
XdrStream.Write(_handle);
452-
XdrStream.WriteBuffer(epb.ToArray());
448+
XdrStream.WriteBuffer(epbData);
453449
XdrStream.Write(AddressOfAstRoutine);
454450
XdrStream.Write(ArgumentToAstRoutine);
455-
XdrStream.Write(events.LocalId);
451+
XdrStream.Write(remoteEvent.LocalId);
456452

457453
XdrStream.Flush();
458454

459455
GenericResponse response = (GenericResponse)ReadResponse();
460456

461-
events.RemoteId = response.ObjectHandle;
457+
remoteEvent.RemoteId = response.ObjectHandle;
462458
}
463459
catch (IOException ex)
464460
{
@@ -477,8 +473,6 @@ public void CancelEvents(RemoteEvent events)
477473
XdrStream.Flush();
478474

479475
ReadResponse();
480-
481-
_eventManager.CancelEvents(events);
482476
}
483477
catch (IOException ex)
484478
{
@@ -584,6 +578,10 @@ public virtual int NextOperation()
584578
{
585579
return _xdrStream.ReadNextOperation();
586580
}
581+
public virtual Task<int> NextOperationAsync()
582+
{
583+
return _xdrStream.ReadNextOperationAsync();
584+
}
587585

588586
public virtual IResponse ReadResponse()
589587
{

0 commit comments

Comments
 (0)