ClaimedMagneticStripeReader.ReleaseDeviceRequested 이벤트
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
디바이스가 배타적 클레임을 해제하라는 요청을 받을 때 발생합니다.
// Register
event_token ReleaseDeviceRequested(EventHandler<ClaimedMagneticStripeReader> const& handler) const;
// Revoke with event_token
void ReleaseDeviceRequested(event_token const* cookie) const;
// Revoke with event_revoker
ClaimedMagneticStripeReader::ReleaseDeviceRequested_revoker ReleaseDeviceRequested(auto_revoke_t, EventHandler<ClaimedMagneticStripeReader> const& handler) const;
public event System.EventHandler<ClaimedMagneticStripeReader> ReleaseDeviceRequested;
function onReleaseDeviceRequested(eventArgs) { /* Your code */ }
claimedMagneticStripeReader.addEventListener("releasedevicerequested", onReleaseDeviceRequested);
claimedMagneticStripeReader.removeEventListener("releasedevicerequested", onReleaseDeviceRequested);
- or -
claimedMagneticStripeReader.onreleasedevicerequested = onReleaseDeviceRequested;
Public Custom Event ReleaseDeviceRequested As EventHandler(Of ClaimedMagneticStripeReader)
이벤트 유형
예제
다음 예제에서는 이벤트 처리기를 설정하는 방법을 보여 있습니다.
void Scenario1::ScenarioStartReadButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
create_task(CreateDefaultReaderObject()).then([this](void)
{
if (_reader != nullptr)
{
// Claim the magnetic stripe reader for exclusive use by your application.
create_task(ClaimReader()).then([this](void)
{
if (_claimedReader)
{
// Add a release device requested event handler. If this event is not handled,
// another app can claim the magnetic stripe reader.
_releaseDeviceRequestedToken = _claimedReader->ReleaseDeviceRequested::add(ref new EventHandler<ClaimedMagneticStripeReader^>(this, &Scenario1::OnReleaseDeviceRequested));
// Add a data receive event handler.
_bankCardDataReceivedToken = _claimedReader->BankCardDataReceived::add(ref new TypedEventHandler<ClaimedMagneticStripeReader^, MagneticStripeReaderBankCardDataReceivedEventArgs^>(this, &Scenario1::OnBankCardDataReceived));
UpdateReaderStatusTextBlock("Attached the BankCardDataReceived event handler..");
// Set the app to decode the raw data from the magnetic stripe reader.
_claimedReader->IsDecodeDataEnabled = true;
// Enable the magnetic stripe reader.
create_task(EnableReader()).then([this](void)
{
UpdateReaderStatusTextBlock("Ready to Swipe..");
// Reset the button state
ScenarioEndReadButton->IsEnabled = true;
ScenarioStartReadButton->IsEnabled = false;
});
}
});
}
});
}
private async void ScenarioStartReadButton_Click(object sender, RoutedEventArgs e)
{
if (await CreateDefaultMagneticStripeReaderObject())
{
if (_reader != null)
{
// Claim the reader for exclusive use by your application.
if (await ClaimReader())
{
if (_claimedReader != null)
{
/// Add a release device requested event handler. If this event is not handled,
// another app can claim the magnetic stripe reader.
_claimedReader.ReleaseDeviceRequested += OnReleaseDeviceRequested;
// Add a data receive event handler.
_claimedReader.BankCardDataReceived += OnBankCardDataReceived;
UpdateReaderStatusTextBlock("Attached the BankCardDataReceived Event handler..");
// Set the app to decode the raw data from the magnetic stripe reader.
_claimedReader.IsDecodeDataEnabled = true;
// Enable the magnetic stripe reader.
if (await EnableReader())
{
UpdateReaderStatusTextBlock("Ready to Swipe..");
// Reset the button state
ScenarioEndReadButton.IsEnabled = true;
ScenarioStartReadButton.IsEnabled = false;
}
}
}
}
}
}
void Scenario1::OnReleaseDeviceRequested(Platform::Object ^sender, Windows::Devices::PointOfService::ClaimedMagneticStripeReader ^args)
{
// Always retain the device. If it is not retained, this exclusive claim will be lost.
args->RetainDevice();
}
void OnReleaseDeviceRequested(object sender, ClaimedMagneticStripeReader args)
{
// Always retain the device. If it is not retained, this exclusive claim will be lost.
args.RetainDevice();
}