When I attempt to run my skeletal tracking code to test out the following line of code I have added in, it crashes with an error.
void sensor_AllFramesReady(object sender, AllFramesReadyEventArgs e)
{
if (closing)
{
return;
}
//Get a skeleton
Skeleton first = GetFirstSkeleton(e);
if (first == null)
{
return;
}
using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
{
//if (skeletonFrame == null)
//{
// return;
//}
this.recordStream = new MemoryStream(100);
KinectRecorder Recorder = new KinectRecorder(KinectRecordOptions.Skeletons, recordStream);
if (skeletonFrame != null)
{
this.Recorder.Record(skeletonFrame);
}
//StartRecord
// Skeleton[] skeletonData = this.Recorder.Record(skeletonFrame);
}
// some more stuff
}
I am calling the Record function available in the Kinect Toolbox.
The error is: System.NullReferenceException was unhandled ....... Message=Object reference not set to an instance of an object.
..... Source=SkeletalTracking
Update:
If I have moved the initialization into the same function as the call of the recorder.
Based on the code you've posted, you never initialize your KinectRecorder.
this.Recorder.Record(skeletonFrame); // I get an error after the RGB camera view freezes
... would produce a null pointer, because Recorder was never initialized. Unless you've left that part out of your code example here. You can do it at the time you declare it, or later if you prefer.
KienctRecorder Recorder = new KinectRecorder(options, stream);
options need to be set up for your appropriate KinectRecordOptions. stream is your output Stream.
Related
I keep getting this error in word, excel powerpoint how can i fix it
Error=The message filter indicated that the application is busy.
(Execption from HRESULT: 0x8001010A(RPC_E_SERVERCALL_RETRYLATER))
foreach (Presentation document in Globals.ThisAddIn.Application.Presentations.Cast<Presentation>().ToList())
{
while (document.ReadOnly!= Microsoft.Office.Core.MsoTriState.msoTrue)
{
break;
}
var item = FODocumentRepository.GetByLocalPath(document.FullName);
if (item == null)
{
if (DocHelper.IfFileOrbisDocument(document.FullName))
{
FODocumentRepository.Add(document.FullName, document.FullName);
}
}
}
var repositoryList = FODocumentRepository.GetAll().ToList();
// var abc = Globals.ThisAddIn.Application.Workbooks.Cast<Workbook>().Select(x => x.FullName).ToList();
List<FODocument> deleteList = new List<FODocument>();
foreach (var item in repositoryList)
{
bool founded = false;
foreach (Presentation document in Globals.ThisAddIn.Application.Presentations)
{
if (item.LocalPath == document.FullName)
{
founded = true;
break;
}
}
if (!founded)
{
MessageBox.Show("DocumentClosed");
FileorbisConflictManager.DocumentClosed(ServiceSettings.GetToken(), DocHelper.GetDocumentKey(item.FOPath),DocumentType.PowerPoint);
deleteList.Add(item);
}
}
foreach (var item in deleteList)
{
FODocumentRepository.Remove(item.LocalPath);
}
These kind of errors occur due to threading contention issues between external multi-threaded applications and Visual Studio. They can be eliminated by implementing IOleMessageFilter error handlers in your Visual Studio automation application. Read more about that in the How to: Fix 'Application is Busy' and 'Call was Rejected By Callee' Errors article.
Also you can find the same issue described on the Exception thread.
I have developed an eclipse plugin in xtext and I need to write some messages in console.
To do that, I have seen this site http://wiki.eclipse.org/FAQ_How_do_I_write_to_the_console_from_a_plug-in%3F and then I have implemented this code:
private static MessageConsole findConsole(String name) {
if (ConsolePlugin.getDefault() == null)
return null;
ConsolePlugin plugin = ConsolePlugin.getDefault();
IConsoleManager conMan = plugin.getConsoleManager();
IConsole[] existing = conMan.getConsoles();
for (int i = 0; i < existing.length; i++)
if (name.equals(existing[i].getName())) {
conMan.showConsoleView(existing[i]);
return (MessageConsole) existing[i];
}
// no console found, so create a new one
MessageConsole myConsole = new MessageConsole(name, null);
conMan.addConsoles(new IConsole[] { myConsole });
return myConsole;
}
public MessageConsoleStream getMessageStream() {
MessageConsole myConsole = findConsole("console");
if (myConsole != null) {
IWorkbench wb = PlatformUI.getWorkbench();
IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
IWorkbenchPage page = win.getActivePage();
String id = IConsoleConstants.ID_CONSOLE_VIEW;
IConsoleView view;
try {
view = (IConsoleView) page.showView(id);
view.display(myConsole);
return myConsole.newMessageStream();
} catch (PartInitException e) {
e.printStackTrace();
}
}
return null;
}
I have added org.eclipse.ui.console to plugin.xml > dependencies > required plugins.
When I want to print some message:
MessageConsoleStream out = getMessageStream();
out.println(...);
And it is working. But I need a "terminate button" in my console and it seems that this code isn't enough.
How can I do that?
Thanks.
That has nothing to do with the console at all. You want to create a viewContribution, which simply adds a button to the tool bar area of an existing view. There is also an example on stackoverflow. Or you might want to consult the Eclipse help on that topic.
I'm wondering if anyone has encountered this before:
I handle a command, and in the handler, I save an event to the eventstore (joliver).
Right after dispatching, the handler for the same command is handled again.
I know its the same command because the guid on the command is the same.
After five tries, nservicebus says the command failed due to the maximum retries.
So obviously the command failed, but I don't get any indication of what failed.
I've put the contents of the dispatcher in a try catch, but there is no error caught. After the code exits the dispatcher, the event handler will always fire as if something errored out.
Tracing through the code, the events are saved to the database (I see the row), the dispatcher runs, and the Dispatched column is set to true, and then the handler handles the command again, the process repeats, and another row gets inserted into the commits table.
Just what could be failing? Am I not setting a success flag somewhere in the event store?
If I decouple the eventstore from nServicebus, both will run as expected with no retries and failures.
The dispatcher:
public void Dispatch(Commit commit)
{
for (var i = 0; i < commit.Events.Count; i++)
{
try
{
var eventMessage = commit.Events[i];
var busMessage = (T)eventMessage.Body;
//bus.Publish(busMessage);
}
catch (Exception ex)
{
throw ex;
}
}
}
The Wireup.Init()
private static IStoreEvents WireupEventStore()
{
return Wireup.Init()
.LogToOutputWindow()
.UsingSqlPersistence("EventStore")
.InitializeStorageEngine()
.UsingBinarySerialization()
//.UsingJsonSerialization()
// .Compress()
//.UsingAsynchronousDispatchScheduler()
// .DispatchTo(new NServiceBusCommitDispatcher<T>())
.UsingSynchronousDispatchScheduler()
.DispatchTo(new DelegateMessageDispatcher(DispatchCommit))
.Build();
}
I had a transaction scope opened on the save that I never closed.
public static void Save(AggregateRoot root)
{
// we can call CreateStream(StreamId) if we know there isn't going to be any data.
// or we can call OpenStream(StreamId, 0, int.MaxValue) to read all commits,
// if no commits exist then it creates a new stream for us.
using (var scope = new TransactionScope())
using (var eventStore = WireupEventStore())
using (var stream = eventStore.OpenStream(root.Id, 0, int.MaxValue))
{
var events = root.GetUncommittedChanges();
foreach (var e in events)
{
stream.Add(new EventMessage { Body = e });
}
var guid = Guid.NewGuid();
stream.CommitChanges(guid);
root.MarkChangesAsCommitted();
scope.Complete(); // <-- missing this
}
}
After successfully opening Pop3Folder, and retrieving messages from it, I then sometimes get to the point, when folder.isOpen returns false. At the same time, when looking at the Pop3Folder's fields in debug mode, I see that the field opened set to true.
Could somebody give me a hint, what might go wrong here?
Here is the code:
public void popMail(MessageProcessor messageProcessor) throws MessagingException {
Folder inboxFolder = null;
Store store = null;
try {
store = mailSession.getStore();
store.connect(mailSession.getProperty("mail.user"),
mailSession.getProperty("mail.password"));
// OK. Connected to POP3 Store.
inboxFolder = store.getFolder("inbox");
inboxFolder.open(Folder.READ_WRITE);
// The folder is successfully opened.
Message[] msgs = inboxFolder.getMessages();
// Messages are successfully retrieved.
if (msgs != null && msgs.length > 0) {
for (Message msg : msgs) {
if (messageProcessor != null) {
// Calling custom listener to process message
messageProcessor.processMessage(msg);
}
msg.setFlag(Flag.DELETED, true);
}
}
} finally {
// Oops, inboxFolder.isOpen returns false.
// Meanwhile I see in debug mode that inboxFolder#opened is set to true
if (inboxFolder != null && inboxFolder.isOpen()) {
try {
inboxFolder.close(true);
} catch (MessagingException e) {
log.warn("Error while closing folder");
}
} if (store != null) {
try {
store.close();
} catch (MessagingException e) {
log.warn("Error while closing store");
}
}
}
}
The server may be timing out the connection if your processMessage method takes too long. Turn on Session debugging and examine the protocol trace for clues.
I have a WCF service that is processing a call, sending that processed data onto another service, and alerting the caller and any other instances of that application by firing a callback. Originally the callbacks were being called at the end but I found that if the second service was not running that there would be a twenty second delay while we attempted to discover it. Only then were the callbacks called. I moved the callback notification before the call to the second service but it still had the delay. I even tried firing the callbacks on a background process but that didn't work either. Is there a way to get around this delay, outside of changing the timeout of the discovery? Here is a code snippet.
// Alert the admins of the change.
if (alertPuis)
{
ReportBoxUpdated(data.SerialNumber);
}
// Now send the change to the box if he's online.
var scope = new Uri(string.Format(#"net.tcp://{0}", data.SerialNumber));
var boxAddress = DiscoveryHelper.DiscoverAddress<IAtcBoxService>(scope);
if (boxAddress != null)
{
var proxy = GetBoxServiceProxy(boxAddress);
if (proxy != null)
{
proxy.UpdateBox(boxData);
}
else
{
Log.Write("AtcSystemService failed on call to update toool Box: {0}",
data.SerialNumber);
}
}
else if (mDal.IsBoxDataInPendingUpdates(data.SerialNumber) == false)
mDal.AddPendingUpdate(data.SerialNumber, null, true, null);
}
and
private static void ReportBoxUpdated(string serialNumber)
{
var badCallbacks = new List<string>();
Action<IAtcSystemServiceCallback> invoke = callback =>
callback.OnBoxUpdated(serialNumber);
foreach (var theCallback in AdminCallbacks)
{
var callback = theCallback.Value as IAtcSystemServiceCallback;
try
{
invoke(callback);
}
catch (Exception ex)
{
Log.Write("Failed to execute callback for admin instance {0}: {1}",
theCallback.Key, ex.Message);
badCallbacks.Add(theCallback.Key);
}
}
foreach (var bad in badCallbacks) // Clean out any stale callbacks from the list.
{
AdminCallbacks.Remove(bad);
}
}
Have you considered caching the result?