x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

Trigger Event on Multithread

Hello, I want to use another thread to listen to other device's socket data receiving,the thread may wait for the data to receive. I tried using Rama's Multi-Threading: How_to_Create_Threads_in_UE4 to do some easy calculations, and it succeed. Could any one give me some suggestion on how to call customized event on thread?

Product Version: UE 4.13
Tags:
more ▼

asked Sep 30 '16 at 05:42 AM in C++ Programming

avatar image

lookoutking
1 1 2

avatar image Shadowriver Sep 30 '16 at 07:54 AM

Can you say how you want to call function/event? which thread should execute that function?

avatar image lookoutking Sep 30 '16 at 08:25 AM

I wanted to make the FRunnable thread wait for data from a server and utilize the data to the game as soon as it becomes available as for I don't want to let the game main thread check for this frequently.

Do I need to let the AActor class inherit from the FRunnable class? Or some mechanism can let me call the event within the Run() function I implement? Thanks!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

You can't communicate with UObjects from diffrent thread so you can't make it runnable. You could try using delegates but i'm not sure if this gonna work. If you trying to communicate with HTTP then use HTTP module APIs insted, it already have implemented multithreading, looking on source it does checking via ticking.

Ticking is not bad as it might look CPUs now days is very very fast and if you check if result varable is accessable as delivered form other thread it technically nothing for it it won't take even 1ms

more ▼

answered Sep 30 '16 at 10:54 AM

avatar image

Shadowriver
35.7k 926 168 1104

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question