As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Is it possible to use TPL in C++/CLI?
Major materials I find relate to PPL, not TPL. If I try to use TPL as I used for C# (e.g. retrieving result of an async operation, via ->Result), then get something like
Error 150 error C2039: 'Result' : is not a member of 'System::Threading::Tasks::Task`1'
Any samples or good tutorials? Thanks
You forgot to post a code snippet so your problem is pretty undiagnosable. Be sure to use Task<TResult> to have a Result property. This sample code compiled and ran without trouble.
#include "stdafx.h"
#using <System.Core.dll>
using namespace System;
using namespace System::Threading::Tasks;
ref class SomeTask {
public:
static int run() {
return 42;
}
};
int main(array<System::String ^> ^args)
{
Task<int>^ task = Task<int>::Factory->StartNew(gcnew Func<int>(&SomeTask::run));
task->Wait();
Console::WriteLine(task->Result);
return 0;
}
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
OK, this is pretty much what I'm trying to do.
I've got a HUGE static library full of functions, which has to be NON-ARC (because of errors).
Now my app has to be ARC-enabled.
However : when ever I'm trying to compile my app, it throws all errors related to my using the NON-arc library.
Any ideas on how this can be solved?
Combining ARC with MRC is not at all a problem. In fact, you do it every day, as many system frameworks are not implemented using ARC, yet.
So, what are your errors?
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm having issues with one of the practise questions given by my teacher. I don't even understand what the question is asking, so any help would be appreciated.
"To practise methods and classes write a class with a method that throws an exception. Write another method for the class that invokes the previous method, catches and handles the exception. Test your code using a main function."
The only thing I understand is testing it with the main function. Any help would be greatly appreciated, thanks.
what you are looking for is a method that contains a try/catch statement
#try {
//do something
}
#catch (NSException *exception){
//do something if the code in the try failed
//OR
#throw exception; //this will make the method called "above" this method handle the exception (eg a method calling another method, that fails, passes the exception back to the top level one)
}
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm learning this from a 'newish' book, but I'm wondering what the current standard is as to the use of the dot operator for things outside of setting property values.
As in method calls and whatnot. Obviously myClass.myMethod:value is syntactically correct, but is it an accepted norm nowadays?
The dot operator is much more 'human' feeling than [myClass myMethod:myValue] in my opinion.
Have you tried compiling this? Your example of myClass.myMethod:value is not valid as far as I understand it.
The dot operator is translated by the compiler to either -(void)setMyValue:(ValueType*) or -(ValueType*)myValue depending on if you are getting or setting it.
Read the apple documentation for more info:
http://developer.apple.com/library/ios/documentation/cocoa/conceptual/objectivec/Chapters/ocObjectsClasses.html#//apple_ref/doc/uid/TP30001163-CH11-SW17
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
Can I make POST or GET requests from an iphone application?
In this article, the second answer mentions 'Assume your class has a responseData instance variable, then.' What does this mean and how would I add one?
Thanks!
In your class's header file, there will be a section along these lines:
#interface YourClass : NSObject {
NSMutableData *responseData;
}
// Soem method declarations here
#end
Inside, the braces, add a declaration for the instance variable you want:
#interface YourClass : NSObject {
}
// Soem method declarations here
#end
I'd recommend reading The Objective-C Programming Language if this is unfamiliar to you, because there are a lot of aspects of the language that are more subtle than this.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Im confused. This is a blog entry of Ayende Rahien Repository is the new singleton.
I believe that a repository should only do CRUD operations and not addtional queries otherwise youll end up with methods like these on your repository.
FindCustomer(id)
FindCustomerWithAddresses(id)
FindCustomerWith..
So my question is, where(in what layer) would one do the queries to retrieve entities?
It's possible to write repository which have default CRUD operations. For example:
public interface IRepository<TEntity>
{
TEntity FindByIdentity(object identity);
TEntity FindBy(Expression<Func<TEntity, bool>> specification);
IList<TEntity> FindAll();
IList<TEntity> FindAllBy(Expression<Func<TEntity, bool>> specification);
TEntity Save(TEntity saveable);
void Delete(TEntity deletable);
}
Expression> is basically Specification and queries can be encapsulate that way. If we have that kind of Repository then we don't need to write many specific repositories.
Alternative path is create Query object. We could add interface of that query to Core/Busines Logic layer and implementation to Services/Data layer. That way we have nicely named queries like AllPreferredCustomersQuery. It's quite similar to specifications, but specifications don't use infrastructure and therefore we may add it to Core/Business Logic layer. Query objects are more configurable (e.g. possible to add limits, fetching strategies, joins etc.)