Strange WPF error - c#

I have some code that works intermittently and I can't understand why (worked perfectly until today morning when windows automatically installed some updates, but none related to .NET 4 - version used in my project).
My password box ...
<PasswordBox x:Name="TboxPassword" Grid.Row="1" Grid.Column="0"
controls:TextboxHelper.Watermark="Password ..."
controls:TextboxHelper.ClearTextButton="True"
Margin="10, 10, 0, 0">
<i:Interaction.Behaviors>
<misc:PasswordBoxBehavior Password="{Binding Path=Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True}"/>
</i:Interaction.Behaviors>
</PasswordBox>
My behavior:
public class PasswordBoxBehavior : Behavior<PasswordBox>
{
#region Fields
private readonly object _tryToExecuteActionSyncObject = new object();
private bool _isUpdating;
#endregion
#region Properties
public string Password
{
get { return (string)GetValue(PasswordProperty); }
set { SetValue(PasswordProperty, value); }
}
public static readonly DependencyProperty PasswordProperty =
DependencyProperty.Register("Password", typeof(string), typeof(PasswordBoxBehavior),
new PropertyMetadata(string.Empty, OnPasswordPropertyChanged));
#endregion
#region Methods
protected override void OnAttached()
{
base.OnAttached();
AssociatedObject.PasswordChanged += OnAssociatedObjectPasswordChanged;
}
protected override void OnDetaching()
{
base.OnDetaching();
AssociatedObject.PasswordChanged -= OnAssociatedObjectPasswordChanged;
}
private void OnAssociatedObjectPasswordChanged(object sender, RoutedEventArgs e)
{
TryToExecuteAction(() => Password = AssociatedObject == null
? string.Empty
: AssociatedObject.Password);
}
private static void OnPasswordPropertyChanged
(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
PasswordBoxBehavior passwordBoxBehavior;
if (sender == null
|| (passwordBoxBehavior = sender as PasswordBoxBehavior) == null
|| passwordBoxBehavior.AssociatedObject == null)
{
return;
}
passwordBoxBehavior.TryToExecuteAction
(() => passwordBoxBehavior.AssociatedObject.Password =
(e.NewValue == null
? string.Empty
: (string) e.NewValue));
}
private void TryToExecuteAction(Action actionToExecute)
{
bool continueExecution;
lock (_tryToExecuteActionSyncObject)
{
continueExecution = _isUpdating == false;
_isUpdating = true;
}
if (continueExecution == false)
{
return;
}
try
{
if (actionToExecute != null)
{
actionToExecute();
}
}
finally
{
lock (_tryToExecuteActionSyncObject)
{
_isUpdating = false;
}
}
}
#endregion
}
I get 0 (zero) compilation errors. When running the application, 90% of the time I'm getting a runtime exception stating that:
{"Cannot add instance of type 'PasswordBoxBehavior' to a collection of type 'BehaviorCollection'. Only items of type 'T' are allowed."}
Debugger stops at the tag Interaction.Behaviors
Please keep in mind that I never received this error until today. Now I receive it even after I revert everything I done today.
Please advise .. :D
PS: I just commented out all the code from inside the behavior. Also removed the Password binding. Still doesn't work :(
PPS: If I close Visual Studio (2012), delete my bin folder, open VS, open project, rebuild all, the application WORKS until the first change to the code.

I know this question is very old. But I will post the answer in case someone face it again.
I just came across the same issue and I found a solution, I noticed that you are using behaviors in your code. Just make sure that your are referencing the right version of Blend SDK Windows.Interactivity
In my case the problem was that I installed the NugetPackage for Blend SDK for WPF 4.5 only on the main WPF project, and I forgot to install it on the other WPF projects in the solution that uses behaviors.
I solved the problem by installing the same NugetPackage on the project containing the code causing the problem.
Hope this helps you!

Blend SDK Windows.Interactivity has been abandoned, and the file System.Windows.Interactivity.dll has been removed from GAC. Use Microsoft.Xaml.Behaviors.Wpf instead, you can install it from Nuget.org.
If you switch the "interactive library" from Blend SDK Windows.Interactivity(System.Windows.Interactivity) to Microsoft.Xaml.Behaviors.Wpf(Microsoft.Xaml.Behaviors)
You can:
Remove System.Windows.Interactivity reference from project.
Close/Unload this solution/project, and open the solution/project directory.
Delete belows folders :.vs, bin, obj.
Reopen/Reload the solution/project.
Replace all namespace of System.Windows.Interactivity to Microsoft.Xaml.Behaviors
Build the solution/project.
Then it will be fine.

Related

How to perform Wix Upgrade with custom bootstrapper

I want to enable Upgrade in the 2nd version of our WiX custom BA installer. In my Product.wxs, Product ID is set to *, version is set to 2.0.0, and upgrade code remains the same as the 1st version's. To detect Upgrade, I used DetectRelatedBundle event handler in the Boostrapper.
The MajorUpgrade tag in the MSI looks like this:
<MajorUpgrade AllowDowngrades="no" DowngradeErrorMessage="A newer version of [ProductName] is already installed." AllowSameVersionUpgrades="no" Schedule="afterInstallInitialize" />
In my installer UI, I have an Install button. When this button is clicked during Upgrade scenario, I call PlanAction and pass LaunchAction.Install. But once installation starts, it shows another instance of BA, which I believe is the old package called by my current BA to uninstall the old version. In order to hide the new BA instance and just show installation progress, I made these changes in my Bootstrapper:
Bootstrapper.cs:
protected override void Run()
{
BootstrapperDispatcher = Dispatcher.CurrentDispatcher;
try
{
_model = new BootstrapperApplicationModel(this);
var uninstall = new UpgradeUninstall(_model);
if (uninstall.IsUpgradeUninstallation())
{
uninstall.PerformSequence();
}
else
{
//show install or uninstall main UI
this.WireUpEventHandlers();
_model.BootstrapperApplication.Engine.Detect();
Dispatcher.Run();
}
}
}
UpgradeUninstall.cs:
public class UpgradeUninstall
{
private BootstrapperApplicationModel _bootStrapperModel;
public UpgradeUninstall(BootstrapperApplicationModel model)
{
_bootStrapperModel = model;
}
public void Perform()
{
this.WireUpEventHandlers();
_bootStrapperModel.BootstrapperApplication.Engine.Detect();
}
public bool IsUpgradeUninstallation()
{
var action = _bootStrapperModel.BootstrapperApplication.Command.Action;
var display = _bootStrapperModel.BootstrapperApplication.Command.Display;
return action == LaunchAction.Uninstall && (display == Display.None || display == Display.Embedded);
}
private void WireUpEventHandlers()
{
_bootStrapperModel.BootstrapperApplication.DetectComplete += OnDetectComplete;
_bootStrapperModel.BootstrapperApplication.PlanComplete += OnPlanComplete;
_bootStrapperModel.BootstrapperApplication.ApplyComplete += OnApplyComplete;
}
private void OnDetectComplete(object sender, DetectCompleteEventArgs e)
{
this._bootStrapperModel.PlanAction(LaunchAction.Uninstall);
}
private void OnPlanComplete(object sender, PlanCompleteEventArgs e)
{
this._bootStrapperModel.ApplyAction();
}
private void OnApplyComplete(object sender, ApplyCompleteEventArgs e)
{
BootstrapperDispatcher.InvokeShutdown();
}
}
Question 1) How will I let my main BA instance (the one doing installation) know that uninstallation of old package has completed? What's happening now is that it was able to successfully uninstall the old package, but no installation of the new version is being performed.
Question 2) Is my understanding of WiX upgrade correct? :)
What is happening is your old BA is getting called in silent mode with the uninstall switch. I can see your code does have some of the plumbing to handle a command line uninstall although I can't see where you're calling Engine.Plan(LaunchAction.Uninstall).
Q1) I don't believe you have to do anything in particular to let your original BA know you're finished. You just need to exit the install in the normal way.
Q2) Yes I think you're almost there. I suggest you download the WIX source code off git to see how it implements its custom BA. Specifically look at the DetectComplete code:
private void DetectComplete(object sender, DetectCompleteEventArgs e)
{
// Parse the command line string before any planning.
this.ParseCommandLine();
this.root.InstallState = InstallationState.Waiting;
if (LaunchAction.Uninstall == WixBA.Model.Command.Action)
{
WixBA.Model.Engine.Log(LogLevel.Verbose, "Invoking automatic plan for uninstall");
WixBA.Plan(LaunchAction.Uninstall);
}
You can see it is checking for the uninstall command line option and immediately kicking off an uninstall.

UWP app release version hangs on splash screen?

Debug versions (86, 64, ARM) all work fine, release versions build fine, but when they run all that happens is my app window opens and remains blank (white background). The only errors I see in the output are a whole bunch of:
...PDB file was not present when IL code was compiled to native.
I'm not sure if the missing .pdb files are the culprit - pretty sure they're not, cause they're just for debugging purposes right?
Anyways, this is the first UWP app I have tried to get ready for the Windows Store, and not completely sure if I have to do anything special like sign it to test release versions on my own computer?
Edit 1: Thank you #Alan for your suggestions, manually uninstalling the app sometimes gets me past the blank window to load the app bar, but then I am getting these errors when it doesn't hang on the splash screen:
Debugger Error 1,
Debugger Error 2
I have done nothing special to the splash screen, loaded all my visual assets using the built in tools in manifest, and have not modified App.xaml.cs from its default. Here is my Mainpage.cs:
using Sublist.Classes;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
namespace Sublist
{
public sealed partial class MainPage : Page
{
const string TAG = "MainPage: ";
// for loading and saving user data and settings
public static DataHandler dataHandler;
public static MasterList<Entry> masterList;
//public static int listViewSelectedIndex = -1;
public MainPage()
{
this.InitializeComponent();
dataHandler = new DataHandler(this);
masterList = new MasterList<Entry>();
// load user data
if (dataHandler.userDataList != null)
masterList = dataHandler.userDataList;
masterList.UpdateListView(this);
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
dataHandler.LoadUserSettings();
}
private void AppBarAdd_Click(object sender, RoutedEventArgs e)
{
masterList.AddRow(this);
}
private void AppBarRemove_Click(object sender, RoutedEventArgs e)
{
if (!(mainListView.SelectedIndex < 0))
{
masterList.RemoveRow(this);
}
}
private void AppBarMoveDown_Click(object sender, RoutedEventArgs e)
{
}
private void AppBarMoveUp_Click(object sender, RoutedEventArgs e)
{
}
private void AppBarIndent_Click(object sender, RoutedEventArgs e)
{
// indent the row control if currently selected index is a list view item
if (-1 < mainListView.SelectedIndex && mainListView.SelectedIndex < mainListView.Items.Count)
{
// but don't allow more than one indent past above row's indent level
RowControl rc = (RowControl)mainListView.Items[mainListView.SelectedIndex];
int indexMinus1 = mainListView.SelectedIndex - 1;
if (-1 < indexMinus1 && rc.indentProp <= masterList[indexMinus1].indent)
{
rc.indentProp++;
}
}
// then update list view
masterList.UpdateListView(this);
}
private void AppBarUnindent_Click(object sender, RoutedEventArgs e)
{
// unindent the row control if currently selected index is a list view item
if (-1 < mainListView.SelectedIndex && mainListView.SelectedIndex < mainListView.Items.Count)
{
// but don't allow unindenting off left side of page
RowControl rc = (RowControl)mainListView.Items[mainListView.SelectedIndex];
if (rc.indentProp > 0)
{
rc.indentProp--;
}
}
// then update list view
masterList.UpdateListView(this);
}
public void AppBarShowCompl_Click(object sender, RoutedEventArgs e)
{
dataHandler.SaveUserSettings();
masterList.UpdateListView(this);
}
public void AppBarMarkAsCompleted_Click(object sender, RoutedEventArgs e)
{
// toggle hidden state of active entry
if (-1 < mainListView.SelectedIndex && mainListView.SelectedIndex < masterList.Count)
{
masterList[mainListView.SelectedIndex].completed = (masterList[mainListView.SelectedIndex].completed) ? false : true;
masterList.UpdateListView(this);
}
}
}
}
I have added the FileService and SettingsService classes from the opensource Template10 to the project.
The build setting "compile with .NET Native tool chain" was unchecked, I've tried deploying with it checked/unchecked for both debug/release versions, and now the debug version also often hangs on the splash screen? With it checked, I get a whole bunch of these errors as well:
'Sublist.exe' (Win32): Loaded 'C:\Windows\System32\biwinrt.dll'. Skipped loading symbols. Module is native, and native debugging is currently disabled.
I've tried downloading the server symbols with no success...
I found the hang happens at the following line in GetIfFileExitsAsync.
retval = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync(key);
I made the following change in you code and it should work now.
In DataHandler's constructor, use Task.Run to initialize the userDataList.
public DataHandler(MainPage mp)
{
mainPage = mp;
settingsHelper = new SettingsHelper();
fileHelper = new FileHelper();
LoadUserSettings();
Task.Run(() =>
{
userDataList = LoadUserData();
});
Task.WaitAll();
}
I am still not sure why the .net native compile will make this issue, but will try to simplify the project and report it in MS internal channel.

Calling .NET Assembly from PowerBuilder (Exposing .NET Framework Components to COM)

Here is the programming environment.
Framework: ASP.NET Framework 4
Language: Visual C# 2010, PowerBuilder 12.5.2 Build 5609 Built on Jan 2 2014 at 01:29:51
Here is the scenario.
I'm creating a PowerBuilder application that fires up a simple window with a multi-line editing textbox where you can type something in there and click a button to load a C# COM class that checks for spelling errors and returns the value back to the PowerBuilder application's textbox.
C# ClassLibrary.cs
using System;
using System.Runtime.InteropServices;
namespace InteropServices
{
[Guid("Let's just assume that I have a correct Guid string here.")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface ISpellChecker
{
[(DispId(1)]
string CheckText(string inputMsg);
[(DispId(2)]
void Dispose();
}
[ClassInterface(ClassInterfaceType.None)]
[Guid("Let's just assume that I have a correct Guid string here.")]
[ProgId("InteropServices.SpellChecker")]
public class SpellChecker: ISpellChecker
{
private string newInputMsg
public string inputMsg
{
get
{
return newInputMsg;
}
set
{
newInputMsg = value;
}
}
private App spellCheckerApp;
private MainWindow spellCheckerMainWindow;
public SpellChecker() { }
public string CheckText(string inputMsgBase)
{
inputMsg = inputMsgBase;
spellCheckerApp = new App();
spellCheckerMainWindow = new MainWindow(inputMsg);
spellCheckerApp.Run(spellCheckerMainWindow);
txtCorrected = MainWindow.TextReturned;
return txtCorrected;
}
public string txtCorrected { get; set; }
// This function was my futile attempt to resolve this issue, but it seemingly has no effect whatsoever.
public void Dispose()
{
spellCheckerMainWindow.Close();
spellCheckerApp.Shutdown();
spellCheckerMainWindow = null;
spellCheckerApp = null;
}
}
}
C# MainWindow.xaml
<Window x:Class="InteropServices.MainWindow"
xmlns="http://schemas.microsft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsft.com/winfx/2006/xaml"
Title="Spell Checker .NET" Height="350" Width="525" Loaded="Window_Loaded">
<Grid>
<TextBox Name="TextBoxSpellCheck" SpellCheck.IsEnabled="True" AcceptsReturn="True" TextWrapping="Wrap" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.CanContentScroll="True" Margin="50" />
<Button Name="ButtonAccept" Margin="229,267,146,12" Width="128" Height="32" Content="Accept" IsDefault="True" Click="ButtonAccept_Click" />
<Button Name="ButtonCancel" Margin="364,267,12,12" Width="128" Height="32" Content="Cancel" IsDefault="True" Click="ButtonAccept_Click" />
</Grid>
</Window>
C# MainWindow.xaml.cs
using System;
// Omitting the rest of the default Usings
namespace InteropServices
{
public partial class MainWindow : Window
{
private string txtChecked;
private int caretIdx;
private SpellingError spellingErr;
private string p;
public MainWindow(string p)
{
this.p = p;
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
txtChecked = p;
TextBoxSpellCheck.Text = txtChecked;
caretIdx = TextBoxSpellCheck.CaretIndex;
spellingErr = TextBoxSpellCheck.GetSpellingError(caretIdx);
if (spellingErr == null)
{
MessageBox.Show("No spelling error was found. Click OK to continue.", "Congratulations!");
txtReturned = p;
Application.Current.Shutdown();
}
}
private void ButtonAccept_Click(object sender, RoutedEventArg e)
{
txtReturned = TextBoxSpellCheck.Text;
Application.Current.Shutdown();
}
private void ButtonCancel_Click(object sender, RoutedEventArg e)
{
txtReturned = p;
Application.Current.Shutdown();
}
public static string txtReturned
}
}
PowerBuilder event clicked for type cb_1 from commandbutton within main
mle_1.Text = "Teh quik brownn fox junps ober teh lazy dgo!" // Too lazy to copy and paste this into the app's textbox, so here it is...
txtChecked = mle_1.Text
myOLEObject = CREATE OLEObject
result = myOLEObject.ConnectToNewObject("InteropServices.SpellChecker")
IF result < 0 THEN
DESTROY myOLEObject
MessageBox("Connecting to COM Object Failed", "Error: " + String(result))
RETURN
ELSE
txtCorrected = myOLEObject.CheckText(txtChecked) // This is the line that causes an error.
mle_1.Text = txtCorrected
END IF
myOLEObject.Dispose() // This function was my futile attempt to resolve this issue, but it seemingly has no effect whatsoever.
myOLEObject.DisconnectObject()
DESTROY myOLEObject
PowerBuilder Instance Variables for main
String txtChecked
String txtCorrected
Int result
OLEObject myOLEObject
The solution that I came up with so far has been acting very weird. Clicking the button from the PowerBuilder application works only once after launching PowerBuilder or the deployed executable, and it would give the following message on further attempts at clicking the button again:
PowerBuilder application execution error (R0035)
Application terminated.
Error: Error calling external object function checktext at line 11 in
clicked event of object cb_1 of main.
What should I change from these codes to make it work every time?
The diagnostic you get from PowerBuilder is entirely too inadequate to ever have a shot at debugging the problem. Best thing to do here is to use the Visual Studio debugger:
Project + Properties, Debug tab. Select the "Start external program" radio button and select your PowerBuilder test program.
Debug + Exceptions, tick the Thrown checkbox for CLR Exceptions. This makes the debugger stop when your program throws an exception.
Set breakpoints at the start of CheckText() and on the statement after the Run() call. One in the Loaded event handler ought to be useful.
Press F5 to start debugging.
When you click the PowerBuilder button, your first breakpoint should hit. Check if you like the inputMsgBase value, press F5 to continue. Press the button again, good odds that the debugger now stops and tells you what is wrong. I have some guesses, nothing I'd risk right now without knowing what you see.

Change App language at RunTime on-the-fly

I'm currently developing a metro app in which the user can change current language at runtime and all the custom controls that are loaded must update their text regarding to the new language. Problem is that when I change the language using the following code, the app language changes but it will only update text when I restart my app because the pages and controls that are already rendered are cached.
LocalizationManager.UICulture = new System.Globalization.CultureInfo((string)((ComboBoxItem)e.AddedItems[0]).Tag);
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = ((ComboBoxItem)e.AddedItems[0]).Tag as String;
What should I do to force updating text of all custom controls at runtime without restarting my app?
Use this:
var NewLanguage = (string)((ComboBoxItem)e.AddedItems[0]).Tag;
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = NewLanguage;
Windows.ApplicationModel.Resources.Core.ResourceContext.GetForViewIndependentUse().Reset();
//Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().Reset();
Windows.ApplicationModel.Resources.Core.ResourceManager.Current.DefaultContext.Reset();
and then reload your Page, using Navigate method:
if (Frame != null)
Frame.Navigate(typeof(MyPage));
In order to respond right away, you would need to reset the context of the resource manager.
For Windows 8.1:
var resourceContext = Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView();
resourceContext.Reset();
You will still need to force your page to redraw itself and thus re-request the resources to get the changes to take place. For Windows 8, you can see https://timheuer.com/blog/archive/2013/03/26/howto-refresh-languages-winrt-xaml-windows-store.aspx
You can change the app's language at runtime with the help of this source code. I took help from this and manipulated my app's language settings page as follows:
In languageSettings.xaml.cs:
public partial class LanguageSettings : PhoneApplicationPage
{
public LanguageSettings()
{
InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (ChangeLanguageCombo.Items.Count == 0)
{ ChangeLanguageCombo.Items.Add(LocalizationManager.SupportedLanguages.En);
ChangeLanguageCombo.Items.Add(LocalizationManager.SupportedLanguages.Bn);
}
SelectChoice();
}
private void ButtonSaveLang_OnClick(object sender, RoutedEventArgs e)
{
//Store the Messagebox result in result variable
MessageBoxResult result = MessageBox.Show("App language will be changed. Do you want to continue?", "Apply Changes", MessageBoxButton.OKCancel);
//check if user clicked on ok
if (result == MessageBoxResult.OK)
{
var languageComboBox = ChangeLanguageCombo.SelectedItem;
LocalizationManager.ChangeAppLanguage(languageComboBox.ToString());
//Application.Current.Terminate(); I am commenting out because I don't neede to restart my app anymore.
}
else
{
SelectChoice();
}
}
private void SelectChoice()
{
//Select the saved language
string lang = LocalizationManager.GetCurrentAppLang();
if(lang == "bn-BD")
ChangeLanguageCombo.SelectedItem = ChangeLanguageCombo.Items[1];
else
{
ChangeLanguageCombo.SelectedItem = ChangeLanguageCombo.Items[0];
}
}
}
***Note: Before understanding what I did on LanguageSettings page's code behind, you must implement the codes from the link as stated earlier. And also it may be noted that I am working on windows phone 8

Pause Kinect Camera - Possible error in SDK reguarding event handler

I'm in the process of converting my Microsoft SDK Beta code to the Microsoft SDK Official Release that was released February 2012.
I added a generic PauseKinect() to pause the Kinect. My pause will really only remove the event handler that updated the image
Pros:
No Reinitialization (30+ second wait time)
Cons:
Kinect still processing images
Pause Method (Color Only)
internal void PauseColorImage(bool isPaused)
{
if (isPaused)
{
_Kinect.ColorFrameReady -= ColorFrameReadyEventHandler;
//_Kinect.ColorStream.Disable();
}
else
{
_Kinect.ColorFrameReady += ColorFrameReadyEventHandler;
//_Kinect.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
}
}
PROBLEM:
Even though I'm removing the event why is it still getting triggered?
NOTE:
Also when I pause the color image I'm also pausing the depth and skeleton in their object.
SIDE NOTE:
If I uncomment my code it works fine, but then it'll take forever to reinitialize which is not what I want to do.
MS in Reflector
public void AddHandler(EventHandler<T> originalHandler)
{
if (originalHandler != null)
{
this._actualHandlers.Add(new ContextHandlerPair<T, T>(originalHandler, SynchronizationContext.Current));
}
}
public void RemoveHandler(EventHandler<T> originalHandler)
{
SynchronizationContext current = SynchronizationContext.Current;
ContextHandlerPair<T, T> item = null;
foreach (ContextHandlerPair<T, T> pair2 in this._actualHandlers)
{
EventHandler<T> handler = pair2.Handler;
SynchronizationContext context = pair2.Context;
if ((current == context) && (handler == originalHandler))
{
item = pair2;
break;
}
}
if (item != null)
{
this._actualHandlers.Remove(item);
}
}
public void Invoke(object sender, T e)
{
if (this.HasHandlers)
{
ContextHandlerPair<T, T>[] array = new ContextHandlerPair<T, T>[this._actualHandlers.Count];
this._actualHandlers.CopyTo(array);
foreach (ContextHandlerPair<T, T> pair in array)
{
EventHandler<T> handler = pair.Handler;
SynchronizationContext context = pair.Context;
if (context == null)
{
handler(sender, e);
}
else if (this._method == ContextSynchronizationMethod<T>.Post)
{
context.Post(new SendOrPostCallback(this.SendOrPostDelegate), new ContextEventHandlerArgsWrapper<T, T>(handler, sender, e));
}
else if (this._method == ContextSynchronizationMethod<T>.Send)
{
context.Send(new SendOrPostCallback(this.SendOrPostDelegate), new ContextEventHandlerArgsWrapper<T, T>(handler, sender, e));
}
}
}
}
After posting an identical question on the Microsoft forum and talking to multiple Microsoft representatives they basically said the only way to do a "pause" is to enable/disable the streams (uncomment my comments). Without saying it straight forward its a bug in the SDK. They are going to talk to the people in the development team and try to fix the issue in future releases.
EDIT
In the May 2012 Release it is STILL not fixed. Thanks Microsoft!

Categories

Resources